Add a workflow to update the changelog #36
This file contains 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: build | |
env: | |
GRADLE_OPTS: "-Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dkotlin.incremental=false" | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: [linux-x64, linux-arm64, windows-x64, windows-arm64, macos-arm64] | |
outputs: | |
version: ${{ steps.properties.outputs.version }} | |
changelog: ${{ steps.properties.outputs.changelog }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: zulu | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Export Properties | |
id: properties | |
shell: bash | |
run: | | |
cat CHANGELOG.md | |
PROPERTIES="$(./gradlew properties --console=plain -q)" | |
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')" | |
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)" | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "changelog<<EOF" >> $GITHUB_OUTPUT | |
echo "$CHANGELOG" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Check style | |
run: ./gradlew ktlintCheck | |
- name: Build unix binary | |
if: ${{ contains(matrix.target, 'macos') || contains(matrix.target, 'linux') }} | |
run: | | |
VARIANT=$(echo ${{ matrix.target }} | sed -E 's/-x64/X64/; s/-arm64/Arm64/') | |
./gradlew "${VARIANT}Binary" | |
- name: Archive vat-${{ matrix.target }} | |
if: ${{ contains(matrix.target, 'macos') || contains(matrix.target, 'linux') }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: vat-${{ matrix.target }} | |
path: build/libs/vat-${{ matrix.target }} | |
- name: Build windows jar | |
if: ${{ contains(matrix.target, 'windows') }} | |
run: | | |
VARIANT=$(echo ${{ matrix.target }} | sed -E 's/-x64/X64/; s/-arm64/Arm64/') | |
./gradlew ${VARIANT}Optimize | |
- name: Archive vat-${{ matrix.target }}.jar | |
if: ${{ contains(matrix.target, 'windows') }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: vat-${{ matrix.target }}.jar | |
path: build/libs/vat-${{ matrix.target }}.jar | |
# 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 | |
- name: Download vat | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/dist | |
merge-multiple: true | |
- name: Generate SHA-256 checksums | |
run: | | |
cd ${{ github.workspace }}/dist | |
for file in ./*; do | |
sha256sum "$file" | cut -d ' ' -f 1 > "$file.sha256" | |
done | |
# Remove old release drafts by using the curl request for the available releases with 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 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 ${{ needs.build.outputs.version }} ${{ github.workspace }}/dist/* \ | |
--draft \ | |
--title "${{ needs.build.outputs.version }}" \ | |
--notes "$(cat << 'EOM' | |
${{ needs.build.outputs.changelog }} | |
EOM | |
)" |