|
| 1 | +# This workflow uses actions that are not certified by GitHub. |
| 2 | +# They are provided by a third-party and are governed by |
| 3 | +# separate terms of service, privacy policy, and support documentation. |
| 4 | +# This workflow will download a prebuilt Java version, install dependencies, build and deploy/publish a new release |
| 5 | +# For more information see: https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven |
| 6 | + |
| 7 | +name: Deploy and Publish |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_run: |
| 11 | + workflows: ["Build and Test"] |
| 12 | + branches: [ master ] |
| 13 | + types: |
| 14 | + - completed |
| 15 | + |
| 16 | + # Allows you to run this workflow manually from the Actions tab |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +jobs: |
| 20 | + deploy: |
| 21 | + if: "!contains(github.event.head_commit.message, 'skip ci')" |
| 22 | + name: Deploy and Publish |
| 23 | + env: |
| 24 | + MVN_ARGS: '-B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn' |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v2 |
| 29 | + with: |
| 30 | + persist-credentials: false |
| 31 | + |
| 32 | + - name: Set up Java |
| 33 | + uses: actions/setup-java@v2 |
| 34 | + with: |
| 35 | + java-version: '8' |
| 36 | + distribution: 'adopt' |
| 37 | + |
| 38 | + - name: Build Java package |
| 39 | + run: mvn verify -fae -DskipITs -Dskip.unit.tests $MVN_ARGS |
| 40 | + |
| 41 | + - name: Setup Node |
| 42 | + uses: actions/setup-node@v1 |
| 43 | + with: |
| 44 | + node-version: 12 |
| 45 | + |
| 46 | + - name: Install Semantic Release dependencies |
| 47 | + run: | |
| 48 | + sudo apt-get install bumpversion |
| 49 | + npm install -g semantic-release |
| 50 | + npm install -g @semantic-release/changelog |
| 51 | + npm install -g @semantic-release/exec |
| 52 | + npm install -g @semantic-release/git |
| 53 | + npm install -g @semantic-release/github |
| 54 | + npm install -g @semantic-release/commit-analyzer |
| 55 | + npm install -g @semantic-release/release-notes-generator |
| 56 | +
|
| 57 | + - name: Publish to Git Releases and Tags |
| 58 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 59 | + env: |
| 60 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 61 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 62 | + run: npx semantic-release # --dry-run --branches 9520_gha |
| 63 | + |
| 64 | + - name: Publish to Maven Central |
| 65 | + if: startsWith(github.ref, 'refs/tags/v') |
| 66 | + env: |
| 67 | + GHA_TAG: ${{ github.ref }} # non PR only need to get last part |
| 68 | + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} # for .travis.settings.xml |
| 69 | + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} |
| 70 | + run: | |
| 71 | + build/setupSigning.sh |
| 72 | + build/setMavenVersion_gha.sh |
| 73 | + mvn deploy --settings build/.travis.settings.xml -DskipITs -Dskip.unit.tests -P central $MVN_ARGS |
| 74 | +
|
| 75 | + - name: Publish Java docs |
| 76 | + if: startsWith(github.ref, 'refs/tags/v') |
| 77 | + env: |
| 78 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 79 | + GHA_REPO_SLUG: ${{ github.repository }} |
| 80 | + GHA_BRANCH: ${{ github.ref }} # non PR only need to get last part |
| 81 | + GHA_PULL_REQUEST: ${{ github.event.number }} |
| 82 | + GHA_BUILD_NUMBER: ${{ github.run_number }} |
| 83 | + GHA_JOB_NUMBER: ${{ github.job_number }} |
| 84 | + GHA_COMMIT: ${{ github.sha }} |
| 85 | + GHA_TAG: ${{ github.ref }} # for setMavenVersion_gha |
| 86 | + run: | |
| 87 | + build/setMavenVersion_gha.sh |
| 88 | + mvn clean javadoc:aggregate $MVN_ARGS |
| 89 | + build/publish_gha.sh |
0 commit comments