Build Application #20
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 Application | |
on: | |
workflow_dispatch: | |
branches: | |
- 'master' | |
jobs: | |
get-version: | |
name: Get project version | |
outputs: | |
version: ${{ steps.gradle-version.outputs.version }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Get project version | |
id: gradle-version | |
run: | | |
echo "version=$(gradle properties -q | awk '/^version:/ {print $2}')" >> "$GITHUB_OUTPUT" | |
build: | |
name: Gradle Build ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
needs: get-version | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, macos-13, macos-14, windows-latest ] | |
fail-fast: false | |
permissions: | |
id-token: write | |
attestations: write | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Set up JDK 20 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '20' | |
distribution: 'temurin' | |
- name: Setup Gradle | |
uses: gradle/gradle-build-action@v3 | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
########## | |
# Create installer for each platform | |
########## | |
- name: Create MacOS file name | |
if: startsWith(matrix.os, 'mac') | |
run: | | |
echo "OUTPUT_FILE_NAME=fqlite-${{ needs.get-version.outputs.version }}-macOS-$(uname -m).dmg" >> $GITHUB_ENV | |
- name: Create Ubuntu file name | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
echo "OUTPUT_FILE_NAME=fqlite-${{ needs.get-version.outputs.version }}-$(uname -m).deb" >> $GITHUB_ENV | |
- name: Create MacOS installer | |
if: startsWith(matrix.os, 'mac') | |
run: | | |
./gradlew --info --stacktrace jpackage | |
find build/jpackage -name "*.dmg" -exec sh -c 'x="{}"; mv "$x" "${{ env.OUTPUT_FILE_NAME }}"' \; | |
echo "OUTPUT_FILE=$(realpath ${{ env.OUTPUT_FILE_NAME }})" >> $GITHUB_ENV | |
- name: Create Linux installer | |
if: startsWith(matrix.os, 'ubuntu') | |
run: | | |
./gradlew --info --stacktrace jpackage | |
find build/jpackage -name "*.deb" -exec sh -c 'x="{}"; mv "$x" "${{ env.OUTPUT_FILE_NAME }}"' \; | |
echo "OUTPUT_FILE=$(realpath ${{ env.OUTPUT_FILE_NAME }})" >> $GITHUB_ENV | |
- name: Create Windows installer | |
if: startsWith(matrix.os, 'windows') | |
run: | | |
$env:Path += ";%cd%\wix314-binaries"; .\gradlew jpackage --info --stacktrace | |
$file_name = "fqlite-${{ needs.get-version.outputs.version }}-windows.exe" | |
echo "OUTPUT_FILE_NAME=$file_name" >> $env:GITHUB_ENV | |
$exe = Get-ChildItem build\jpackage\*.exe | Select-Object -First 1 | |
$file = Rename-Item -Path "$exe" -NewName "$file_name" -PassThru | |
echo "OUTPUT_FILE=$file" >> $env:GITHUB_ENV | |
$hash = Get-FileHash $file | |
echo "HASH=$($hash[0].hash)" >> $env:GITHUB_ENV | |
########## | |
# Generate artefact attestation | |
########## | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-path: "${{ env.OUTPUT_FILE }}" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: "${{ env.OUTPUT_FILE_NAME }}" | |
path: "${{ env.OUTPUT_FILE }}" | |
overwrite: true | |
retention-days: 14 | |
########## | |
# Package artefacts | |
########## | |
##### | |
# Windows - Chocolatey package | |
##### | |
- name: Prepare chocolatey package installer | |
if: startsWith(matrix.os, 'windows') | |
env: | |
VERSION: ${{ needs.get-version.outputs.version }} | |
run: | | |
cd packaging\choco\ | |
./replace_config.ps1 | |
cd ..\..\ | |
- name: Generate chocolatey package | |
if: startsWith(matrix.os, 'windows') | |
uses: crazy-max/ghaction-chocolatey@v3 | |
with: | |
args: pack packaging/choco/fqlite/fqlite.nuspec --version ${{ needs.get-version.outputs.version }} | |
- uses: actions/upload-artifact@v4 | |
if: startsWith(matrix.os, 'windows') | |
with: | |
name: "fqlite-${{ needs.get-version.outputs.version }}.nupkg" | |
path: "fqlite*.nupkg" | |
overwrite: true | |
retention-days: 14 | |
publish: | |
# if: github.event.pull_request.merged == true | |
name: Publish release artefacts | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- get-version | |
outputs: | |
version: ${{ steps.create-version.outputs.version }} | |
permissions: | |
id-token: write | |
contents: write | |
steps: | |
########## | |
# Upload artefact to release for each platform | |
########## | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: get latest artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
merge-multiple: true | |
path: artifacts/ | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
body_path: CHANGELOG.md | |
tag_name: ${{ needs.get-version.outputs.version }} | |
make_latest: true | |
files: | | |
artifacts/* | |