-
Notifications
You must be signed in to change notification settings - Fork 1
316 lines (274 loc) · 11.1 KB
/
release.yml
File metadata and controls
316 lines (274 loc) · 11.1 KB
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
310
311
312
313
314
315
316
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
permissions:
contents: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: Build (${{ matrix.platform }})
strategy:
matrix:
include:
- os: macos-15
platform: macos
build-path: apple/Products/Release
archive-name: exfig-macos
- os: ubuntu-latest
platform: linux-x64
build-path: x86_64-unknown-linux-gnu/release
archive-name: exfig-linux-x64
container: swift:6.2-jammy
extra-flags: --static-swift-stdlib -Xlinker -lcurl -Xlinker -lxml2 -Xlinker -lssl -Xlinker -lcrypto -Xlinker -lz
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- name: Install Git LFS (Linux)
if: matrix.platform == 'linux-x64'
run: |
apt-get update
apt-get install -y git-lfs
git lfs install
- uses: actions/checkout@v6
with:
lfs: true
- name: Select Xcode 26.1 (macOS)
if: matrix.platform == 'macos'
run: sudo xcode-select -s /Applications/Xcode_26.1.1.app/Contents/Developer
- name: Install system dependencies (Linux)
if: matrix.platform == 'linux-x64'
run: |
apt-get install -y libcurl4-openssl-dev libxml2-dev libssl-dev
- name: Set version from tag
run: |
VERSION="${GITHUB_REF#refs/tags/}"
FILE="Sources/ExFigCLI/ExFigCommand.swift"
if [ "${{ matrix.platform }}" = "macos" ]; then
sed -i '' "s/static let version = \".*\"/static let version = \"$VERSION\"/" "$FILE"
else
sed -i "s/static let version = \".*\"/static let version = \"$VERSION\"/" "$FILE"
fi
- name: Build release binary (macOS)
if: matrix.platform == 'macos'
run: |
# Build each architecture separately to avoid xcodebuild issues with binary targets
swift build -c release --arch arm64
swift build -c release --arch x86_64
# Create universal binary
mkdir -p .build/apple/Products/Release
lipo -create \
.build/arm64-apple-macosx/release/exfig \
.build/x86_64-apple-macosx/release/exfig \
-output .build/apple/Products/Release/exfig
# Copy resource bundles from arm64 build (they're arch-independent)
cp -r .build/arm64-apple-macosx/release/*.bundle .build/apple/Products/Release/
- name: Build release binary (Linux)
if: matrix.platform == 'linux-x64'
run: swift build -c release ${{ matrix.extra-flags }}
- name: Create release archive (macOS)
if: matrix.platform == 'macos'
run: |
mkdir -p dist
cp .build/${{ matrix.build-path }}/exfig dist/ExFig
cp -r .build/${{ matrix.build-path }}/exfig_AndroidExport.bundle dist/
cp -r .build/${{ matrix.build-path }}/exfig_XcodeExport.bundle dist/
cp -r .build/${{ matrix.build-path }}/exfig_FlutterExport.bundle dist/
cp -r .build/${{ matrix.build-path }}/exfig_WebExport.bundle dist/
cp -r .build/${{ matrix.build-path }}/exfig_ExFigCLI.bundle dist/
cp LICENSE dist/
cd dist && zip -r ../${{ matrix.archive-name }}.zip .
- name: Create release archive (Linux)
if: matrix.platform == 'linux-x64'
run: |
mkdir -p dist
cp .build/${{ matrix.build-path }}/exfig dist/ExFig
cp -r .build/${{ matrix.build-path }}/exfig_AndroidExport.resources dist/
cp -r .build/${{ matrix.build-path }}/exfig_XcodeExport.resources dist/
cp -r .build/${{ matrix.build-path }}/exfig_FlutterExport.resources dist/
cp -r .build/${{ matrix.build-path }}/exfig_WebExport.resources dist/
cp -r .build/${{ matrix.build-path }}/exfig_ExFigCLI.resources dist/
cp LICENSE dist/
cd dist && tar -czf ../${{ matrix.archive-name }}.tar.gz -- *
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.archive-name }}
path: |
${{ matrix.archive-name }}.zip
${{ matrix.archive-name }}.tar.gz
if-no-files-found: ignore
update-version:
name: Update Version and Changelog
needs: build
if: ${{ !contains(github.ref, '-') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update version in main branch
run: |
VERSION="${GITHUB_REF#refs/tags/}"
FILE="Sources/ExFigCLI/ExFigCommand.swift"
sed -i "s/static let version = \".*\"/static let version = \"$VERSION\"/" "$FILE"
sed -i "s/version = \".*\"/version = \"${VERSION#v}\"/" "Sources/ExFigCLI/Resources/Schemas/PklProject"
- name: Update CHANGELOG.md
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --output CHANGELOG.md
env:
GITHUB_REPO: ${{ github.repository }}
- name: Commit and push
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Sources/ExFigCLI/ExFigCommand.swift Sources/ExFigCLI/Resources/Schemas/PklProject CHANGELOG.md
git diff --staged --quiet || git commit -m "chore(release): bump version to ${GITHUB_REF#refs/tags/v}"
git push origin main
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate release notes
id: changelog
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --latest --strip header
env:
GITHUB_REPO: ${{ github.repository }}
- name: Install Pkl CLI
run: |
curl -sL https://github.com/apple/pkl/releases/download/0.30.2/pkl-linux-amd64 -o /usr/local/bin/pkl
chmod +x /usr/local/bin/pkl
- name: Update PklProject version
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
sed -i "s/version = \".*\"/version = \"$VERSION\"/" Sources/ExFigCLI/Resources/Schemas/PklProject
- name: Package PKL schemas
run: |
pkl project package \
--output-path ".pkl-out/%{name}@%{version}/" \
Sources/ExFigCLI/Resources/Schemas
- name: Generate shell completions
run: |
set -euo pipefail
USAGE_VERSION="2.18.2"
curl --fail -sL "https://github.com/jdx/usage/releases/download/v${USAGE_VERSION}/usage-x86_64-unknown-linux-gnu.tar.gz" -o usage.tar.gz
tar xzf usage.tar.gz
chmod +x usage/bin/usage
mkdir -p completions
usage/bin/usage generate completion bash exfig -f exfig.usage.kdl > completions/exfig.bash
usage/bin/usage generate completion zsh exfig -f exfig.usage.kdl > completions/_exfig
usage/bin/usage generate completion fish exfig -f exfig.usage.kdl > completions/exfig.fish
for f in completions/exfig.bash completions/_exfig completions/exfig.fish; do
if [[ ! -s "$f" ]]; then
echo "::error::Generated completion file is empty: $f"
exit 1
fi
done
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.content }}
prerelease: ${{ contains(github.ref, '-') }}
files: |
artifacts/exfig-macos/exfig-macos.zip
artifacts/exfig-linux-x64/exfig-linux-x64.tar.gz
.pkl-out/exfig@*/*
completions/exfig.bash
completions/_exfig
completions/exfig.fish
update-homebrew:
name: Update Homebrew Tap
needs: release
if: ${{ !contains(github.ref, '-') }}
runs-on: ubuntu-latest
steps:
- name: Get version from tag
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
- name: Download release assets and calculate SHA256
id: sha
run: |
VERSION="${{ steps.version.outputs.version }}"
curl -sL "https://github.com/alexey1312/ExFig/releases/download/v${VERSION}/exfig-macos.zip" -o exfig-macos.zip
MACOS_SHA=$(sha256sum exfig-macos.zip | cut -d' ' -f1)
echo "macos=${MACOS_SHA}" >> "$GITHUB_OUTPUT"
curl -sL "https://github.com/alexey1312/ExFig/releases/download/v${VERSION}/exfig-linux-x64.tar.gz" -o exfig-linux.tar.gz
LINUX_SHA=$(sha256sum exfig-linux.tar.gz | cut -d' ' -f1)
echo "linux=${LINUX_SHA}" >> "$GITHUB_OUTPUT"
- name: Checkout Homebrew tap
uses: actions/checkout@v6
with:
repository: alexey1312/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap
- name: Update formula
run: |
VERSION="${{ steps.version.outputs.version }}"
MACOS_SHA="${{ steps.sha.outputs.macos }}"
LINUX_SHA="${{ steps.sha.outputs.linux }}"
FORMULA="homebrew-tap/Formula/exfig.rb"
sed -i "s/version \".*\"/version \"${VERSION}\"/" "$FORMULA"
sed -i "0,/sha256 \"[a-f0-9]*\"/s//sha256 \"${MACOS_SHA}\"/" "$FORMULA"
sed -i "0,/sha256 \"${MACOS_SHA}\"/! {0,/sha256 \"[a-f0-9]*\"/s//sha256 \"${LINUX_SHA}\"/}" "$FORMULA"
cat "$FORMULA"
- name: Commit and push
working-directory: homebrew-tap
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/exfig.rb
git diff --staged --quiet || git commit -m "chore: bump to v${{ steps.version.outputs.version }}"
git push
deploy-docs:
name: Deploy DocC
needs: release
if: ${{ !contains(github.ref, '-') }}
runs-on: macos-15
timeout-minutes: 30
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
env:
DEVELOPER_DIR: "/Applications/Xcode_26.1.1.app/Contents/Developer"
steps:
- uses: actions/checkout@v6
- name: Build DocC
run: |
swift package --allow-writing-to-directory docs \
generate-documentation --target ExFigCLI \
--disable-indexing \
--transform-for-static-hosting \
--hosting-base-path ExFig \
--output-path docs
echo '<script>window.location.href += "/documentation/exfigcli"</script>' > docs/index.html
- uses: actions/upload-pages-artifact@v4
with:
path: 'docs'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4