Skip to content

Build Desktop Release #12

Build Desktop Release

Build Desktop Release #12

Workflow file for this run

# The name of the workflow
name: Build Desktop Release
# The trigger for the workflow
on:
release:
types: [ published ]
# This allows the upload-release-asset step to write to the release.
permissions:
contents: write
# The jobs to be run
jobs:
build:
strategy:
matrix:
os: [ macos-latest, windows-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
# 1: Check out the code
- name: Check out repository
uses: actions/checkout@v4
# 2: Set up the Java JDK
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
# 3: Grant execute permission to gradlew (for macOS and Linux)
- name: Grant execute permission for gradlew
if: matrix.os != 'windows-latest'
run: chmod +x gradlew
# 4: Build the app
- name: Build with Gradle
run: ./gradlew packageReleaseDistribution
# This step finds the installer file and saves its full path to an output variable.
- name: Find Artifact Path
id: find_artifact
run: |
$ARTIFACT_PATH = (Get-ChildItem -Path "shared/build/compose/binaries/main-release" -Recurse -Include "*.msi", "*.dmg", "*.deb").FullName
echo "path=$ARTIFACT_PATH" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
shell: pwsh
if: matrix.os == 'windows-latest'
- name: Find Artifact Path (Unix)
id: find_artifact_unix
run: |
ARTIFACT_PATH=$(find shared/build/compose/binaries/main-release -type f \( -name "*.dmg" -o -name "*.deb" \))
echo "path=${ARTIFACT_PATH}" >> $GITHUB_OUTPUT
shell: bash
if: matrix.os != 'windows-latest'
# 5: Upload the generated installer to the release
- name: Upload Release Artifact
uses: actions/upload-release-asset@v1
with:
repo-token: ${{ secrets.PAT }}
upload_url: ${{ github.event.release.upload_url }}
# This now uses the exact path found in the previous step, avoiding the wildcard bug.
asset_path: ${{ steps.find_artifact.outputs.path || steps.find_artifact_unix.outputs.path }}
asset_name: |
${{ matrix.os == 'windows-latest' && 'AgeCalculator-windows-installer.msi' || '' }}
${{ matrix.os == 'macos-latest' && 'AgeCalculator-macOS-installer.dmg' || '' }}
${{ matrix.os == 'ubuntu-latest' && 'AgeCalculator-linux-installer.deb' || '' }}
asset_content_type: application/octet-stream