ci: publish from the release workflow #3
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
| name: Release | |
| on: | |
| push: | |
| branches: [main] | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| verify: | |
| name: Verify release | |
| uses: ./.github/workflows/build.yml | |
| release: | |
| name: Cut release | |
| needs: verify | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| revision: ${{ steps.version.outputs.revision }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| # year.build, resetting the build number when the year changes. | |
| - name: Bump version | |
| id: version | |
| run: | | |
| CURRENT_YEAR="$(date +%y)" | |
| CURRENT="$(sed -n 's|^version=||p' gradle.properties)" | |
| YEAR="${CURRENT%%.*}" | |
| BUILD="${CURRENT##*.}" | |
| if [[ "$YEAR" != "$CURRENT_YEAR" ]]; then | |
| YEAR="$CURRENT_YEAR" | |
| BUILD=0 | |
| fi | |
| BUILD=$((BUILD + 1)) | |
| REVISION="$YEAR.$BUILD" | |
| sed -i "s|^version=.*|version=$REVISION|" gradle.properties | |
| # Badge and the version users copy out of the install snippet. | |
| sed -i \ | |
| -e "s|version-[^-]*-blue|version-$REVISION-blue|" \ | |
| -e "s|id(\"net.blueva.mawu\") version \"[^\"]*\"|id(\"net.blueva.mawu\") version \"$REVISION\"|" \ | |
| README.md | |
| echo "revision=$REVISION" >> "$GITHUB_OUTPUT" | |
| echo "Releasing Mawu $REVISION" | |
| # Pushes made with GITHUB_TOKEN don't retrigger this workflow, so | |
| # [skip ci] is just extra insurance. | |
| - name: Commit version bump | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add gradle.properties README.md | |
| git commit -m "build(release): bump version to ${{ steps.version.outputs.revision }} [skip ci]" | |
| git push | |
| - name: Tag release | |
| run: | | |
| git tag "v${{ steps.version.outputs.revision }}" | |
| git push origin "v${{ steps.version.outputs.revision }}" | |
| - name: Publish GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release create "v${{ steps.version.outputs.revision }}" --title "Mawu ${{ steps.version.outputs.revision }}" --generate-notes | |
| # A tag pushed with GITHUB_TOKEN does not start another workflow, so the | |
| # release publishes rather than waiting for publish.yml to notice the tag. | |
| publish: | |
| name: Publish to repo.blueva.net | |
| needs: release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: v${{ needs.release.outputs.revision }} | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v6 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@v6 | |
| - name: Publish the plugin and the runtime | |
| run: ./gradlew publishAllPublicationsToBluevaRepoRepository --no-daemon --stacktrace | |
| env: | |
| RELEASE_VERSION: ${{ needs.release.outputs.revision }} | |
| BLUEVA_REPO_USERNAME: ${{ secrets.BLUEVA_REPO_USERNAME }} | |
| BLUEVA_REPO_SECRET: ${{ secrets.BLUEVA_REPO_SECRET }} |