|
| 1 | +name: semantic-gitlog |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +env: |
| 6 | + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} |
| 7 | + OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} |
| 8 | + OSSRH_GPG_SECRET_ID: ${{ secrets.OSSRH_GPG_SECRET_ID }} |
| 9 | + OSSRH_GPG_SECRET_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_PASSWORD }} |
| 10 | + |
| 11 | + MAVEN_LOG_OPTS: -D org.slf4j.simpleLogger.showDateTime=true -D org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss.SSS |
| 12 | + MAVEN_CLI_OPTS: -B -V -e -ff ${MAVEN_LOG_OPTS} |
| 13 | + DEPLOY_CLI_OPTS: -B -V -e -ff ${MAVEN_LOG_OPTS} --settings .mvn/mvn-settings.xml -P mvn-release |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + if: startsWith(github.event.head_commit.message, 'bumped version to ') != true |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Set up JDK 1.8 |
| 27 | + uses: actions/setup-java@v1 |
| 28 | + with: |
| 29 | + java-version: 1.8 |
| 30 | + |
| 31 | + - name: Cache dependencies |
| 32 | + uses: actions/cache@v1 |
| 33 | + with: |
| 34 | + path: ~/.m2 |
| 35 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 36 | + restore-keys: ${{ runner.os }}-m2- |
| 37 | + |
| 38 | + - name: Prepare to build |
| 39 | + run: | |
| 40 | + chmod +x ./mvnw |
| 41 | + git show-ref |
| 42 | + git log --graph --full-history --all --color --date=short --pretty=format:"%Cred%x09%h %Creset%ad%Cgreen%d %Creset %s %C(bold)(%an)%Creset" || true |
| 43 | +
|
| 44 | + - name: Build project |
| 45 | + run: ./mvnw ${{env.MAVEN_CLI_OPTS}} clean install -DskipTests=true |
| 46 | + |
| 47 | + test: |
| 48 | + needs: [build] |
| 49 | + runs-on: ubuntu-latest |
| 50 | + |
| 51 | + if: startsWith(github.event.head_commit.message, 'bumped version to ') != true |
| 52 | + |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v2 |
| 55 | + with: |
| 56 | + fetch-depth: 0 |
| 57 | + |
| 58 | + - name: Set up JDK 1.8 |
| 59 | + uses: actions/setup-java@v1 |
| 60 | + with: |
| 61 | + java-version: 1.8 |
| 62 | + |
| 63 | + - name: Cache dependencies |
| 64 | + uses: actions/cache@v1 |
| 65 | + with: |
| 66 | + path: ~/.m2 |
| 67 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 68 | + restore-keys: ${{ runner.os }}-m2- |
| 69 | + |
| 70 | + - name: Prepare to build |
| 71 | + run: chmod +x ./mvnw |
| 72 | + |
| 73 | + - name: Run tests |
| 74 | + run: ./mvnw ${{env.MAVEN_CLI_OPTS}} clean test |
| 75 | + |
| 76 | + deploy_snapshot: |
| 77 | + needs: [build, test] |
| 78 | + runs-on: ubuntu-latest |
| 79 | + |
| 80 | + if: (github.ref == 'refs/heads/master') && startsWith(github.event.head_commit.message, 'bumped version to ') != true && startsWith(github.event.head_commit.message, 'release:') != true |
| 81 | + |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v2 |
| 84 | + with: |
| 85 | + fetch-depth: 0 |
| 86 | + |
| 87 | + - name: Set up JDK 1.8 |
| 88 | + uses: actions/setup-java@v1 |
| 89 | + with: |
| 90 | + java-version: 1.8 |
| 91 | + |
| 92 | + - name: Cache dependencies |
| 93 | + uses: actions/cache@v1 |
| 94 | + with: |
| 95 | + path: ~/.m2 |
| 96 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 97 | + restore-keys: ${{ runner.os }}-m2- |
| 98 | + |
| 99 | + - name: Prepare to build |
| 100 | + run: chmod +x ./mvnw |
| 101 | + |
| 102 | + - id: install-secret-key |
| 103 | + name: Install gpg secret key |
| 104 | + run: | |
| 105 | + echo "${{ secrets.OSSRH_GPG_SECRET_KEY }}" | base64 -d | gpg --batch --import |
| 106 | +
|
| 107 | + - id: publish |
| 108 | + name: Publish snapshot |
| 109 | + run: | |
| 110 | + newVersion=`./mvnw ${{env.DEPLOY_CLI_OPTS}} -D gitlog.toRef=${{github.ref}} -D gitlog.preRelease='' semantic-gitlog:derive -U | grep 'NEXT_VERSION:==' | sed 's/^.*NEXT_VERSION:==//g'` |
| 111 | +
|
| 112 | + echo "newVersion: ${newVersion}" |
| 113 | +
|
| 114 | + ./mvnw ${{env.DEPLOY_CLI_OPTS}} -D "newVersion=${newVersion}" versions:set 1>/dev/null 2>/dev/null |
| 115 | + ./mvnw ${{env.DEPLOY_CLI_OPTS}} -D skipTests=true clean deploy |
| 116 | +
|
| 117 | + deploy_release: |
| 118 | + needs: [build] |
| 119 | + runs-on: ubuntu-latest |
| 120 | + |
| 121 | + if: startsWith(github.ref, 'refs/tags/') && startsWith(github.event.head_commit.message, 'release') |
| 122 | + |
| 123 | + steps: |
| 124 | + - uses: actions/checkout@v2 |
| 125 | + with: |
| 126 | + fetch-depth: 0 |
| 127 | + |
| 128 | + - name: Set up JDK 1.8 |
| 129 | + uses: actions/setup-java@v1 |
| 130 | + with: |
| 131 | + java-version: 1.8 |
| 132 | + |
| 133 | + - name: Cache dependencies |
| 134 | + uses: actions/cache@v1 |
| 135 | + with: |
| 136 | + path: ~/.m2 |
| 137 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 138 | + restore-keys: ${{ runner.os }}-m2- |
| 139 | + |
| 140 | + - name: Prepare to build |
| 141 | + run: chmod +x ./mvnw |
| 142 | + |
| 143 | + - id: install-secret-key |
| 144 | + name: Install gpg secret key |
| 145 | + run: | |
| 146 | + echo "${{ secrets.OSSRH_GPG_SECRET_KEY }}" | base64 -d | gpg --batch --import |
| 147 | + gpg --list-secret-keys --keyid-format LONG |
| 148 | +
|
| 149 | + - name: Publish release |
| 150 | + run: ./mvnw ${{env.DEPLOY_CLI_OPTS}} -D skipTests=true clean deploy |
0 commit comments