Skip to content

Build Compose Desktop App #6

Build Compose Desktop App

Build Compose Desktop App #6

Workflow file for this run

name: Build Compose Desktop App
on:
workflow_dispatch:
inputs:
tag_name:
description: 'Tag name (e.g., v1.0.0)'
required: true
type: string
push:
tags:
- "v*"
jobs:
build:
strategy:
matrix:
include:
- os: ubuntu-latest
target: linux
- os: windows-latest
target: windows
- os: macos-latest
target: macos-x64
gradle-args: "-Pcompose.desktop.mac.target=x64"
- os: macos-latest
target: macos-arm64
gradle-args: "-Pcompose.desktop.mac.target=arm64"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
# 如果是手动触发,创建tag
- name: Create tag if workflow_dispatch
if: github.event_name == 'workflow_dispatch'
run: |
git tag ${{ github.event.inputs.tag_name }}
git push origin ${{ github.event.inputs.tag_name }}
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Grant execute permission for gradlew
if: runner.os != 'Windows'
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew packageDistributionForCurrentOS ${{ matrix.gradle-args }}
- name: List files
run: ls -R composeApp/build/compose/binaries/main/
- name: Upload Windows artifact
if: matrix.target == 'windows'
uses: actions/upload-artifact@v3
with:
name: windows-distribution
path: composeApp/build/compose/binaries/main/msi/*.msi
- name: Upload macOS x64 artifact
if: matrix.target == 'macos-x64'
uses: actions/upload-artifact@v3
with:
name: macos-x64-distribution
path: composeApp/build/compose/binaries/main/dmg/*.dmg
- name: Upload macOS ARM64 artifact
if: matrix.target == 'macos-arm64'
uses: actions/upload-artifact@v3
with:
name: macos-arm64-distribution
path: composeApp/build/compose/binaries/main/dmg/*.dmg
- name: Upload Linux artifact
if: matrix.target == 'linux'
uses: actions/upload-artifact@v3
with:
name: linux-distribution
path: composeApp/build/compose/binaries/main/deb/*.deb
create-release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: dist
- name: List downloaded files
run: ls -R dist/
- name: Get version
id: get_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "VERSION=${{ github.event.inputs.tag_name }}" >> $GITHUB_OUTPUT
else
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Prepare release files
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
VERSION=${VERSION#v} # Remove 'v' prefix if present
mkdir release
# Copy and rename files
find dist/windows-distribution -name "*.msi" -exec cp {} release/LifeUp-Desktop-${VERSION}-windows.msi \;
find dist/macos-x64-distribution -name "*.dmg" -exec cp {} release/LifeUp-Desktop-${VERSION}-macos-x64.dmg \;
find dist/macos-arm64-distribution -name "*.dmg" -exec cp {} release/LifeUp-Desktop-${VERSION}-macos-arm64.dmg \;
find dist/linux-distribution -name "*.deb" -exec cp {} release/lifeup-desktop_${VERSION}_amd64.deb \;
echo "Release contents:"
ls -la release/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ steps.get_version.outputs.VERSION }}
name: Release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: true
files: release/*
body: |
## LifeUp Desktop Release ${{ steps.get_version.outputs.VERSION }}
### Downloads
- Windows: LifeUp Desktop.msi
- macOS Intel (x64): LifeUp-Desktop-x64.dmg
- macOS Apple Silicon (ARM64): LifeUp-Desktop-arm64.dmg
- Linux: lifeup-desktop.deb