-
Notifications
You must be signed in to change notification settings - Fork 336
250 lines (208 loc) · 8.27 KB
/
release.yml
File metadata and controls
250 lines (208 loc) · 8.27 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
name: Build & Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build-macos:
runs-on: macos-14 # Apple Silicon runner
steps:
- uses: actions/checkout@v4
- name: Install Apple Certificate
env:
CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
run: |
CERT_PATH=$RUNNER_TEMP/certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$CERTIFICATE" | base64 --decode -o $CERT_PATH
security create-keychain -p "" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "" $KEYCHAIN_PATH
security import $CERT_PATH -P "$CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "" $KEYCHAIN_PATH
security list-keychains -d user -s $KEYCHAIN_PATH login.keychain
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: Install dependencies
run: npm install
- name: Build Tauri app (signed + notarized)
env:
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: ""
run: npm run tauri build
- name: Upload macOS artifacts
uses: actions/upload-artifact@v4
with:
name: macos-build
path: |
src-tauri/target/release/bundle/macos/*.app
src-tauri/target/release/bundle/macos/*.app.tar.gz
src-tauri/target/release/bundle/macos/*.app.tar.gz.sig
src-tauri/target/release/bundle/dmg/*.dmg
build-macos-intel:
runs-on: macos-14 # Cross-compile to Intel
steps:
- uses: actions/checkout@v4
- name: Install Apple Certificate
env:
CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
run: |
CERT_PATH=$RUNNER_TEMP/certificate.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$CERTIFICATE" | base64 --decode -o $CERT_PATH
security create-keychain -p "" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "" $KEYCHAIN_PATH
security import $CERT_PATH -P "$CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -k "" $KEYCHAIN_PATH
security list-keychains -d user -s $KEYCHAIN_PATH login.keychain
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-apple-darwin
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: Install dependencies
run: npm install
- name: Build Tauri app (Intel, signed + notarized)
env:
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: ""
run: npm run tauri build -- --target x86_64-apple-darwin
- name: Upload macOS Intel artifacts
uses: actions/upload-artifact@v4
with:
name: macos-intel-build
path: |
src-tauri/target/x86_64-apple-darwin/release/bundle/macos/*.app.tar.gz
src-tauri/target/x86_64-apple-darwin/release/bundle/macos/*.app.tar.gz.sig
src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/*.dmg
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: Install dependencies
run: npm install
- name: Build Tauri app
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ""
run: npm run tauri build
- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: windows-build
path: |
src-tauri/target/release/bundle/nsis/*.exe
src-tauri/target/release/bundle/nsis/*.exe.sig
src-tauri/target/release/bundle/msi/*.msi
src-tauri/target/release/bundle/msi/*.msi.sig
release:
needs: [build-macos, build-macos-intel, build-windows]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get version from tag
id: version
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- name: Download macOS artifacts
uses: actions/download-artifact@v4
with:
name: macos-build
path: artifacts/macos
- name: Download macOS Intel artifacts
uses: actions/download-artifact@v4
with:
name: macos-intel-build
path: artifacts/macos-intel
- name: Download Windows artifacts
uses: actions/download-artifact@v4
with:
name: windows-build
path: artifacts/windows
- name: List artifacts
run: find artifacts -type f | head -30
- name: Generate latest.json for updater
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Read signatures
DARWIN_AARCH64_SIG=$(cat artifacts/macos/macos/*.app.tar.gz.sig 2>/dev/null || echo "")
DARWIN_X86_64_SIG=$(cat artifacts/macos-intel/macos/*.app.tar.gz.sig 2>/dev/null || echo "")
WINDOWS_X86_64_SIG=$(cat artifacts/windows/nsis/*.exe.sig 2>/dev/null || echo "")
REPO="https://github.com/phuc-nt/my-translator/releases/download/v${VERSION}"
# Find actual filenames
DARWIN_AARCH64_FILE=$(ls artifacts/macos/macos/*.app.tar.gz 2>/dev/null | head -1 | xargs basename || echo "")
DARWIN_X86_64_FILE=$(ls artifacts/macos-intel/macos/*.app.tar.gz 2>/dev/null | head -1 | xargs basename || echo "")
WINDOWS_X86_64_FILE=$(ls artifacts/windows/nsis/*.exe 2>/dev/null | head -1 | xargs basename || echo "")
cat > artifacts/latest.json << EOF
{
"version": "${VERSION}",
"notes": "See release notes at https://github.com/phuc-nt/my-translator/releases/tag/v${VERSION}",
"pub_date": "${DATE}",
"platforms": {
"darwin-aarch64": {
"signature": "${DARWIN_AARCH64_SIG}",
"url": "${REPO}/${DARWIN_AARCH64_FILE}"
},
"darwin-x86_64": {
"signature": "${DARWIN_X86_64_SIG}",
"url": "${REPO}/${DARWIN_X86_64_FILE}"
},
"windows-x86_64": {
"signature": "${WINDOWS_X86_64_SIG}",
"url": "${REPO}/${WINDOWS_X86_64_FILE}"
}
}
}
EOF
echo "Generated latest.json:"
cat artifacts/latest.json
- name: Create Release
uses: softprops/action-gh-release@v2
with:
draft: true
generate_release_notes: true
files: |
artifacts/**/*.dmg
artifacts/**/*.exe
artifacts/**/*.msi
artifacts/**/*.app.tar.gz
artifacts/**/*.sig
artifacts/latest.json