-
Notifications
You must be signed in to change notification settings - Fork 13
309 lines (263 loc) · 10 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
name: Release
on:
pull_request_target:
types: [closed]
branches: [main]
workflow_dispatch:
jobs:
check_release:
if: |
(github.event_name == 'workflow_dispatch' && github.actor == 'triyanox') ||
(github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release'))
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
should_release: ${{ steps.check_version.outputs.should_release }}
current_version: ${{ steps.check_version.outputs.current_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check version changes
id: check_version
run: |
# Get the latest release version
OLD_VERSION=$(gh release view --json tagName --jq '.tagName' | sed 's/^v//' || echo "0.0.0")
# Get the current version from Cargo.toml
CURRENT_VERSION=$(sed -n '/^\[workspace\.package\]/,/^\[/p' Cargo.toml | grep '^version = ' | cut -d '"' -f 2)
echo "Old version: $OLD_VERSION"
echo "Current version: $CURRENT_VERSION"
if [ "$OLD_VERSION" != "$CURRENT_VERSION" ]; then
echo "Version changed from $OLD_VERSION to $CURRENT_VERSION"
echo "should_release=true" >> "$GITHUB_OUTPUT"
echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
else
echo "Version unchanged"
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
needs: check_release
if: needs.check_release.outputs.should_release == 'true'
name: Build Release Binaries
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux builds
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: lla-linux-amd64
pkg_formats: "deb,rpm,apk,pacman"
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
artifact_name: lla-linux-arm64
cross_compile: true
pkg_formats: "deb,rpm,apk,pacman"
- os: ubuntu-latest
target: i686-unknown-linux-gnu
artifact_name: lla-linux-i686
cross_compile: true
pkg_formats: "deb,rpm,apk,pacman"
# macOS builds
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: lla-macos-amd64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: lla-macos-arm64
steps:
- uses: actions/checkout@v4
- name: Setup Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.71.0
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.cross_compile && runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-i686-linux-gnu
sudo apt-get install -y crossbuild-essential-arm64 crossbuild-essential-i386
- name: Set cross-compilation environment
if: matrix.cross_compile && runner.os == 'Linux'
run: |
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=i686-linux-gnu-gcc" >> $GITHUB_ENV
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
- name: Prepare binary
run: |
cp target/${{ matrix.target }}/release/lla ${{ matrix.artifact_name }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_name }}
publish:
needs: [check_release, build]
if: needs.check_release.outputs.should_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.71.0
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Update dependency version
run: |
VERSION="${{ needs.check_release.outputs.current_version }}"
# Update the version in lla/Cargo.toml
sed -i 's/version = "[0-9]*\.[0-9]*\.[0-9]*"/version = "'$VERSION'"/' lla/Cargo.toml
- name: Check and publish to crates.io
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: |
cargo login ${{ secrets.CRATES_IO_TOKEN }}
# Get current version without 'v' prefix
VERSION="${{ needs.check_release.outputs.current_version }}"
# Check if lla_plugin_interface version exists (using awk to get just the version)
PUBLISHED_VERSION=$(cargo search lla_plugin_interface --limit 1 | awk -F '"' '{print $2}')
if [ "$PUBLISHED_VERSION" != "$VERSION" ]; then
echo "Publishing lla_plugin_interface v$VERSION"
cargo publish -p lla_plugin_interface
# Wait for crates.io indexing
sleep 30
else
echo "lla_plugin_interface v$VERSION already published, skipping..."
fi
# Check and publish lla_plugin_utils
PUBLISHED_VERSION=$(cargo search lla_plugin_utils --limit 1 | awk -F '"' '{print $2}')
if [ "$PUBLISHED_VERSION" != "$VERSION" ]; then
echo "Publishing lla_plugin_utils v$VERSION"
cargo publish -p lla_plugin_utils
# Wait for crates.io indexing
sleep 30
else
echo "lla_plugin_utils v$VERSION already published, skipping..."
fi
echo "Publishing lla v$VERSION"
cargo publish -p lla
create_release:
needs: [check_release, build, publish]
if: needs.check_release.outputs.should_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create themes archive
run: |
find themes -name "*.toml" -type f | zip themes.zip -@
- name: Generate SHA256 checksums
run: |
cd artifacts
for artifact in */*; do
sha256sum "$artifact" >> ../SHA256SUMS
done
cd ..
sha256sum themes.zip >> SHA256SUMS
- name: Create Release Notes
run: |
{
echo "# Release v${{ needs.check_release.outputs.current_version }}"
echo
if [ -f CHANGELOG.md ]; then
echo "## Changelog"
echo
sed -n "/## \[${{ needs.check_release.outputs.current_version }}\]/,/## \[/p" CHANGELOG.md | sed '$d'
echo
fi
echo "## SHA256 Checksums"
echo "\`\`\`"
cat SHA256SUMS
echo "\`\`\`"
} > RELEASE_NOTES.md
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.check_release.outputs.current_version }}
release_name: Release v${{ needs.check_release.outputs.current_version }}
body_path: RELEASE_NOTES.md
draft: false
prerelease: false
- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Upload binaries
for asset in artifacts/*/*; do
filename=$(basename "$asset")
echo "Uploading $filename..."
gh release upload "v${{ needs.check_release.outputs.current_version }}" "$asset" --clobber
done
# Upload themes archive
gh release upload "v${{ needs.check_release.outputs.current_version }}" themes.zip --clobber
# Upload checksums
gh release upload "v${{ needs.check_release.outputs.current_version }}" SHA256SUMS --clobber
package:
needs: [check_release, build]
if: needs.check_release.outputs.should_release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Install nFPM
run: |
echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list
sudo apt update
sudo apt install -y nfpm
nfpm --version
- name: Generate packages
run: |
VERSION="${{ needs.check_release.outputs.current_version }}"
for artifact in artifacts/*; do
if [[ $artifact == *linux* ]]; then
# Generate DEB package
nfpm pkg --packager deb --target "$artifact/lla_${VERSION}_amd64.deb"
# Generate RPM package
nfpm pkg --packager rpm --target "$artifact/lla-${VERSION}-1.x86_64.rpm"
# Generate APK package
nfpm pkg --packager apk --target "$artifact/lla-${VERSION}-r0.apk"
# Generate Pacman package
nfpm pkg --packager archlinux --target "$artifact/lla-${VERSION}-1-x86_64.pkg.tar.zst"
fi
done
- name: Upload packages
uses: actions/upload-artifact@v3
with:
name: packages
path: |
**/*.deb
**/*.rpm
**/*.apk
**/*.pkg.tar.zst