-
Notifications
You must be signed in to change notification settings - Fork 6
222 lines (196 loc) · 8.51 KB
/
Copy pathrelease.yml
File metadata and controls
222 lines (196 loc) · 8.51 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
name: Release
on:
push:
tags: ['v*']
permissions:
contents: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
create-release:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
release_id: ${{ steps.create.outputs.release_id }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Create draft release
id: create
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
run: |
RESPONSE=$(gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/releases \
-f tag_name="${{ github.ref_name }}" \
-f name="PearTree ${{ github.ref_name }}" \
-f body="See the assets below to download PearTree for your platform." \
-F draft=true \
-F prerelease=false)
echo "release_id=$(echo $RESPONSE | jq -r .id)" >> $GITHUB_OUTPUT
build:
needs: create-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: macos-latest
args: '--target universal-apple-darwin'
- platform: ubuntu-22.04
args: ''
- platform: windows-latest
args: ''
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Install Linux dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
- name: Install WiX toolset (Windows)
if: matrix.platform == 'windows-latest'
run: |
Invoke-WebRequest -Uri https://github.com/wixtoolset/wix3/releases/download/wix3141rtm/wix314-binaries.zip -OutFile wix314.zip
Expand-Archive wix314.zip -DestinationPath "$env:USERPROFILE\wix314"
echo "$env:USERPROFILE\wix314" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh
- name: Install Node dependencies
run: npm install
- name: Set version from tag
run: node scripts/set-version.js ${{ github.ref_name }}
- name: Build and upload
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
# macOS code signing & notarization – set these secrets in GitHub repo settings.
# Without them the macOS build will still succeed but will be unsigned.
APPLE_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
APPLE_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
# Tauri updater signing – generate keys with: npx tauri signer generate
# Add the private key + password as GitHub secrets.
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
# Passed to Rust via option_env!() so the About box shows the full tag.
PEARTREE_VERSION_TAG: ${{ github.ref_name }}
with:
releaseId: ${{ needs.create-release.outputs.release_id }}
args: ${{ matrix.args }}
patch-updater-json:
# After all platform builds finish, add the darwin-universal key to latest.json.
# Tauri builds the macOS universal binary but tauri-action writes architecture-specific
# keys (darwin-aarch64 / darwin-x86_64). The running universal app reports its platform
# as "darwin-universal", so the updater fails unless that key exists.
needs: [create-release, build]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Patch darwin-universal into latest.json
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
run: |
# Find the latest.json asset that tauri-action uploaded
ASSET_ID=$(gh api \
/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets \
--jq '.[] | select(.name == "latest.json") | .id')
# Download it (auth required for draft releases)
curl -sSfL \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Accept: application/octet-stream" \
"https://api.github.com/repos/${{ github.repository }}/releases/assets/${ASSET_ID}" \
-o latest.json
# Add darwin-universal (same as darwin-aarch64 – both install the universal binary)
jq '.platforms["darwin-universal"] = .platforms["darwin-aarch64"]' \
latest.json > latest_patched.json
# Replace the asset
gh api --method DELETE \
/repos/${{ github.repository }}/releases/assets/${ASSET_ID}
curl -sSfL \
-X POST \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @latest_patched.json \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=latest.json"
bundle-embed:
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
ref: main
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Node dependencies
run: npm install
- name: Set version from tag
run: node scripts/set-version.js ${{ github.ref_name }}
- name: Build single-file bundle
env:
PEARTREE_VERSION_TAG: ${{ github.ref_name }}
run: npm run bundle
- name: Upload bundle to release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
run: |
curl -sSfL \
-X POST \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @dist/peartree.bundle.min.js \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=peartree.bundle.min.js"
- name: Assemble webapp
run: |
mkdir -p webapp/data webapp/img webapp/logo
cp peartree/index.html webapp/index.html
cp dist/peartree.bundle.min.js webapp/peartree.bundle.min.js
cp peartree/img/peartree.svg webapp/img/peartree.svg
cp peartree/img/peartree.png webapp/img/peartree.png
cp logo/peartree.svg webapp/logo/peartree.svg
cp logo/peartree.png webapp/logo/peartree.png
cp peartree/data/ebov.tree webapp/data/ebov.tree
cp peartree/data/VARV.tree webapp/data/VARV.tree
cp peartree/data/large_tree.tree webapp/data/large_tree.tree
cp peartree/data/SARS-CoV-2_15K.tree webapp/data/SARS-CoV-2_15K.tree
cp peartree/data/ebov.csv webapp/data/ebov.csv
cp peartree/about.md webapp/about.md
cp peartree/help.md webapp/help.md
tar -czf peartree-webapp.tgz -C webapp .
- name: Upload webapp tgz to release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
RELEASE_ID: ${{ needs.create-release.outputs.release_id }}
run: |
curl -sSfL \
-X POST \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Content-Type: application/gzip" \
--data-binary @peartree-webapp.tgz \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets?name=peartree-webapp.tgz"