Post release update - 2.9.0 (#40) #176
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Build | |
on: | |
# Trigger the workflow on pushes to only the 'master' branch (this avoids duplicate checks being run e.g., for dependabot pull requests) | |
push: | |
branches: [ master ] | |
# Trigger the workflow on any pull request | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
# Check out current repository | |
- name: Fetch Sources | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
# Set up Java environment for the next steps | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: zulu | |
java-version: 11 | |
# Setup Gradle | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Build and Test with Gradle | |
run: ./gradlew --no-daemon --continue build | |
# Publish test results | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v2.9.0 | |
if: always() | |
with: | |
files: build/test-results/**/*.xml | |
# Prepare a draft release for GitHub Releases page for the manual verification | |
# If accepted and published, release workflow would be triggered | |
releaseDraft: | |
name: Release draft | |
if: github.event_name != 'pull_request' | |
needs: [ build ] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
# Check out current repository | |
- name: Fetch Sources | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Find the next semantic version based on commits | |
# https://github.com/thenativeweb/get-next-version?tab=readme-ov-file#using-commit-messages | |
- name: Get next version | |
id: get_next_version | |
uses: thenativeweb/get-next-version@2.6.2 | |
# Setup Gradle | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
# Set environment variables | |
- name: Export Changelog | |
id: changelog | |
shell: bash | |
run: | | |
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)" | |
echo "changelog<<EOF" >> $GITHUB_OUTPUT | |
echo "$CHANGELOG" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
# Remove old release drafts by using the curl request for the available releases with a draft flag | |
- name: Remove Old Release Drafts | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh api repos/{owner}/{repo}/releases \ | |
--jq '.[] | select(.draft == true) | .id' \ | |
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{} | |
# Create a new release draft which is not publicly visible and requires manual acceptance | |
- name: Create Release Draft | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create "${{ steps.get_next_version.outputs.version }}" \ | |
--draft \ | |
--title "${{ steps.get_next_version.outputs.version }}" \ | |
--notes "$(cat << 'EOM' | |
${{ steps.changelog.outputs.changelog }} | |
EOM | |
)" |