forked from RealZST/HarnessKit
-
Notifications
You must be signed in to change notification settings - Fork 0
234 lines (203 loc) · 7.38 KB
/
Copy pathrelease.yml
File metadata and controls
234 lines (203 loc) · 7.38 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
name: Release
on:
push:
tags:
- "v*"
env:
MACOSX_DEPLOYMENT_TARGET: "12.0"
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
release_id: ${{ steps.create.outputs.release_id }}
changelog: ${{ steps.changelog.outputs.body }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
BODY=$(gh api repos/${{ github.repository }}/releases/generate-notes \
-f tag_name="${{ github.ref_name }}" \
-f previous_tag_name="$PREV_TAG" \
--jq '.body')
else
BODY=$(gh api repos/${{ github.repository }}/releases/generate-notes \
-f tag_name="${{ github.ref_name }}" \
--jq '.body')
fi
if [ -z "$BODY" ]; then
BODY="Bug fixes and improvements."
fi
# Prepend hand-written highlights from .github/release-notes/<tag>.md
# so they appear both on the GitHub release page and in latest.json
# (which feeds the in-app updater dialog).
HIGHLIGHTS_FILE=".github/release-notes/${{ github.ref_name }}.md"
if [ -s "$HIGHLIGHTS_FILE" ]; then
HIGHLIGHTS=$(cat "$HIGHLIGHTS_FILE")
BODY="$(printf '%s\n\n%s' "$HIGHLIGHTS" "$BODY")"
fi
{
echo "body<<CHANGELOG_EOF"
echo "$BODY"
echo "CHANGELOG_EOF"
} >> "$GITHUB_OUTPUT"
- name: Create draft release
id: create
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Pass body through an env var so any quotes / backticks / $
# characters from auto-generated PR titles or hand-written
# release-notes don't break shell parsing of the `-f body=`
# argument below.
BODY: ${{ steps.changelog.outputs.body }}
run: |
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases \
-f tag_name="${{ github.ref_name }}" \
-f name="HarnessKit ${{ github.ref_name }}" \
-f body="$BODY" \
-F draft=true \
--jq '.id')
echo "release_id=$RELEASE_ID" >> "$GITHUB_OUTPUT"
release-desktop:
needs: create-release
strategy:
matrix:
include:
- target: aarch64-apple-darwin
arch: arm64
- target: x86_64-apple-darwin
arch: x64
runs-on: macos-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install Tauri CLI
run: cargo install tauri-cli --locked
- name: Install frontend dependencies
run: npm ci
- name: Import Apple certificate
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
run: |
if [ -z "$APPLE_CERTIFICATE" ]; then
echo "No certificate provided, skipping"
exit 0
fi
echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12
security create-keychain -p actions build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p actions build.keychain
security set-keychain-settings -t 3600 -u build.keychain
security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k actions build.keychain
rm certificate.p12
- name: Build desktop app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}
# Required so tauri-action populates `latest.json`'s `notes` field;
# without it the in-app updater shows an empty changelog.
releaseBody: ${{ needs.create-release.outputs.changelog }}
tauriScript: cargo tauri
args: --target ${{ matrix.target }}
- name: Build CLI (with embedded web frontend)
run: |
npm run build
cargo build --release --target ${{ matrix.target }} -p hk-cli
- name: Upload CLI to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp "target/${{ matrix.target }}/release/hk" "hk-macos-${{ matrix.arch }}"
gh release upload "${{ github.ref_name }}" "hk-macos-${{ matrix.arch }}" --clobber
release-cli-linux:
needs: create-release
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
key: x86_64-unknown-linux-musl
- name: Install musl toolchain
run: sudo apt-get update && sudo apt-get install -y musl-tools perl make
- name: Install frontend dependencies
run: npm ci
- name: Build CLI (with embedded web frontend)
run: |
npm run build
cargo build --release -p hk-cli --target x86_64-unknown-linux-musl
- name: Upload CLI to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp target/x86_64-unknown-linux-musl/release/hk hk-linux-x64
gh release upload "${{ github.ref_name }}" hk-linux-x64 --clobber
release-cli-windows:
needs: create-release
runs-on: windows-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust cache
uses: swatinem/rust-cache@v2
- name: Install frontend dependencies
run: npm ci
- name: Build CLI (with embedded web frontend)
run: |
npm run build
cargo build --release -p hk-cli
- name: Upload CLI to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
cp target/release/hk.exe hk-windows-x64.exe
gh release upload "${{ github.ref_name }}" hk-windows-x64.exe --clobber