-
Notifications
You must be signed in to change notification settings - Fork 6
146 lines (124 loc) · 4.6 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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