This repository has been archived by the owner on Jan 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
229 lines (196 loc) · 6.89 KB
/
release.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# Release Workflow
# This workflow is triggered when a version tag is pushed and performs the following:
#
# 1. Version Verification:
# - Checks if the version in version.properties matches the tag version
# - Fails if versions don't match, preventing accidental mismatched releases
#
# 2. Build Process:
# - Only proceeds if version verification passes
# - Builds the application and creates release artifacts
#
# To create a release:
# 1. Update version.properties with the new version
# 2. Commit and push the change
# 3. Create and push a tag matching the version (e.g., v1.0.0)
name: Build and Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*' # Semantic versioning tags only
env:
JAVA_VERSION: '17'
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
jobs:
verify-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set version
run: |
# Remove 'v' prefix and trim any whitespace
VERSION=$(echo "${GITHUB_REF_NAME#v}" | tr -d '[:space:]')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check version.properties
id: check_version
run: |
# Check if file exists
if [ ! -f "version.properties" ]; then
echo "::error::version.properties file not found"
exit 1
fi
# Read and validate version
CURRENT_VERSION=$(grep -E "^[[:space:]]*version[[:space:]]*=[[:space:]]*[^[:space:]]" version.properties | head -n 1 | cut -d'=' -f2 | tr -d '[:space:]')
# Check if version was found
if [ -z "$CURRENT_VERSION" ]; then
echo "::error::No valid version found in version.properties"
exit 1
fi
# Debug output
echo "Current version from properties: '$CURRENT_VERSION'"
echo "Version from tag: '${{ env.VERSION }}'"
# Compare versions (case-sensitive)
if [ "$CURRENT_VERSION" != "${{ env.VERSION }}" ]; then
echo "::error::Version mismatch: version.properties ($CURRENT_VERSION) does not match tag (${{ env.VERSION }})"
exit 1
fi
echo "Version check passed: $CURRENT_VERSION"
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
build-jar:
needs: verify-version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
cache: 'gradle'
- name: Set version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build Launcher JAR
run: |
./gradlew clean jar -Pversion=${{ env.VERSION }} --stacktrace || {
echo "Build failed. Checking logs..."
find . -name "*.log" -type f -exec cat {} \;
exit 1
}
- name: Upload JAR artifact
uses: actions/upload-artifact@v3
with:
name: jar
path: build/libs/thymelab-launcher-${{ env.VERSION }}.jar
retention-days: 5
build-installers:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
include:
- os: windows-latest
installer_ext: "exe"
alt_installer_ext: "msi"
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ env.JAVA_VERSION }}
cache: 'gradle'
- name: Set version (Windows)
shell: pwsh
run: echo "VERSION=$($env:GITHUB_REF_NAME -replace '^v','')" >> $env:GITHUB_ENV
- name: Create installer (Windows)
shell: pwsh
run: |
try {
& ./gradlew.bat createInstaller "-Pos=windows" "-Pversion=${{ env.VERSION }}" --stacktrace
} catch {
Write-Host "Installer creation failed. Checking logs..."
Get-ChildItem -Recurse -Filter *.log | Get-Content
exit 1
}
New-Item -ItemType Directory -Force -Path installers
$found = $false
foreach ($ext in @("exe", "msi")) {
$files = Get-ChildItem "build/dist/ThymeLab*.$ext"
if ($files) {
Copy-Item $files.FullName installers/
$found = $true
}
}
if (-not $found) {
Write-Host "No installer files found"
exit 1
}
Get-ChildItem installers/
- name: List build/dist contents (Windows)
shell: pwsh
run: Get-ChildItem build/dist
- name: Upload installer artifact
uses: actions/upload-artifact@v3
with:
name: installer-${{ runner.os }}
path: |
installers/ThymeLab*.${{ matrix.installer_ext }}
installers/ThymeLab*.${{ matrix.alt_installer_ext }}
retention-days: 5
release:
needs: [build-jar, build-installers]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Display structure of downloaded files
run: ls -R
- name: Create Release
uses: softprops/action-gh-release@v1
with:
name: ThymeLab Launcher${{ github.ref_name }}
body: |
## ThymeLab Launcher ${{ github.ref_name }}
### Downloads
- **ThymeLab-${{ env.VERSION }}.exe**: Windows installer
- **thymelab-launcher-${{ env.VERSION }}.jar**: Launcher JAR (requires Java ${{ env.JAVA_VERSION }})
### Installation
- **Windows**: Run ThymeLab-${{ env.VERSION }}.exe
- **Note**: Windows installers are not signed
- When installing, you may see a warning about an unknown publisher
- This is expected as the installers are unsigned
- To proceed with the installation:
1. Right-click the installer and select "Properties"
2. Go to the "General" tab
3. Click "Unblock" if available, then click "OK"
- **macOS**: macOS users need to build the installer locally:
```bash
git clone https://github.com/thkwag/thymelab-launcher.git
cd thymelab-launcher
./gradlew createInstaller -Pos=mac
```
The installer will be created in `build/dist/`
- **All OS**: Run the JAR file
```bash
java -jar thymelab-launcher-${{ env.VERSION }}.jar
```
files: |
jar/thymelab-launcher-${{ env.VERSION }}.jar
installer-Windows/ThymeLab*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}