dxCommon Release #31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # TODO: update conda-forge recipe | |
| name: dxCommon Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release-version: | |
| description: 'dxCommon version' | |
| required: true | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| run-release: | |
| name: dxCommon Release | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Version check | |
| run: | | |
| common_snapshot=`grep -c "SNAPSHOT" ./common/src/main/resources/application.conf || true` | |
| if [ "$common_snapshot" -ne "0" ]; then | |
| echo "dxCommon version contains '-SNAPSHOT'; releases cannot have snapshot versions" | |
| exit 1 | |
| fi | |
| - name: Install java | |
| uses: actions/setup-java@d202f5dbf7256730fb690ec59f6381650114feb2 # v1.4.3 | |
| with: | |
| java-version: 11 | |
| - name: Install SBT | |
| uses: ./.github/workflows/actions/install-sbt | |
| - name: Unit Tests | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| sbt 'project common' test | |
| - name: Assembly | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| sbt 'project common' assembly | |
| mv ./common/target/dxCommon.jar ./dxCommon-${{ github.event.inputs.release-version }}.jar | |
| - name: Scala formatting | |
| run: | | |
| sbt 'project common' scalafmtCheckAll | |
| - name: Extract release notes and set version in application.conf files | |
| id: update-release | |
| run: | | |
| # Update the config file with the newest version | |
| sed -i 's/version.*$/version = "${{ github.event.inputs.release-version }}"/' ./common/src/main/resources/application.conf | |
| # Extract release notes for the release into a temporary (unpushed) file | |
| # It is expected the RELEASE_NOTES.md has already an entry for the version being | |
| # released. The section should start with '## <version>', e.g. ## 1.0.0 2021-01-01 | |
| # The file will be read by the create-release step | |
| RELEASE_NOTES_PATH="./common/release_notes_${{ github.event.inputs.release-version }}.md" | |
| sed -n '/## ${{ github.event.inputs.release-version }}/,/##/p' common/RELEASE_NOTES.md | sed '1d; $d' > $RELEASE_NOTES_PATH | |
| echo ::set-output name=release-notes-path::$(echo "${RELEASE_NOTES_PATH}") | |
| - name: Commit changes to application.conf files | |
| uses: EndBug/add-and-commit@8c12ff729a98cfbcd3fe38b49f55eceb98a5ec02 # v7.5.0 | |
| with: | |
| message: 'Release ${{ github.event.inputs.release-version }}' | |
| add: '[ | |
| "./common/src/main/resources/application.conf" | |
| ]' | |
| push: false | |
| tag: common-${{ github.event.inputs.release-version }} | |
| - name: Create release entry | |
| id: create-release | |
| uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: common-${{ github.event.inputs.release-version }} | |
| release_name: dxCommon ${{ github.event.inputs.release-version }} | |
| body_path: ${{ steps.update-release.outputs.release-notes-path }} | |
| draft: true | |
| prerelease: false | |
| - name: Upload assembly JAR | |
| id: upload-release-assembly | |
| uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| # This pulls from the "Create release entry" step above, referencing it's ID to get its outputs object, | |
| # which include a `upload_url`. See this blog post for more info: | |
| # https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | |
| upload_url: ${{ steps.create-release.outputs.upload_url }} | |
| asset_path: ./dxCommon-${{ github.event.inputs.release-version }}.jar | |
| asset_name: dxCommon-${{ github.event.inputs.release-version }}.jar | |
| asset_content_type: application/jar | |
| - name: Push local release branch and tag to origin | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git pull | |
| git push origin HEAD:${{ github.ref }} | |
| git push origin HEAD:common-${{ github.event.inputs.release-version }} | |
| - name: Publish package | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| sbt 'project common' publish | |
| - name: Rollback release if unsuccessfull | |
| if: ${{ cancelled() || failure() }} | |
| uses: author/action-rollback@f4473931b1155b601092ec00eb1fa4882b80219f # 1.0.4 | |
| with: | |
| release_id: ${{ steps.create-release.outputs.id }} | |
| tag: common-${{ github.event.inputs.release-version }} | |
| delete_orphan_tag: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |