-
Notifications
You must be signed in to change notification settings - Fork 0
272 lines (245 loc) · 9.95 KB
/
Copy pathrelease.yml
File metadata and controls
272 lines (245 loc) · 9.95 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
# Unified release workflow: otomatis terpicu ketika ada push yang mengubah
# zeroscript-extension/manifest.json (umumnya commit bump versi), atau
# dijalankan manual dari tab Actions ("Run workflow").
#
# Alur kerja:
# 1. Job `release` -> ambil versi dari manifest.json (atau input),
# package zip ekstensi, ambil release notes dari CHANGELOG.md, lalu
# buat GitHub Release dengan zip ekstensi terlampir. Dilewati jika
# tag v<versi> sudah pernah dibuat (mis. push menyentuh manifest.json
# tanpa mengubah versi, agar tidak membuat release duplikat).
# 2. Job `build-desktop` (matrix Win/macOS/Linux) -> build Tauri GUI +
# PyInstaller bridge sidecar, lalu lampirkan bundle installer ke
# Release yang sama.
#
# Catatan: workflow "Package Browser Extension" dan "Build Desktop GUI"
# sebelumnya terpisah (trigger pada release: published) sudah digabung
# ke sini. Job `release` sendiri sudah melampirkan zip ekstensi, jadi
# langkah packaging ekstensi tidak perlu diulang.
name: Create Release
on:
push:
branches:
- main
paths:
- zeroscript-extension/manifest.json
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g. 1.0.0). Leave empty to use the version in zeroscript-extension/manifest.json."
required: false
type: string
draft:
description: "Create the release as a draft instead of publishing it."
required: false
type: boolean
default: false
prerelease:
description: "Mark the release as a pre-release."
required: false
type: boolean
default: false
concurrency:
group: create-release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: write
jobs:
# ---------------------------------------------------------------------------
# Job 1: Resolve version, package extension zip, and create the release.
# ---------------------------------------------------------------------------
release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
exists: ${{ steps.version.outputs.exists }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Resolve version and tag
id: version
shell: bash
run: |
set -euo pipefail
VERSION="${{ inputs.version }}"
if [ -z "$VERSION" ]; then
VERSION="$(node -p "require('./zeroscript-extension/manifest.json').version")"
fi
TAG="v${VERSION}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Tag ${TAG} already exists. Release will be skipped."
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Tag ${TAG} does not exist. Release can proceed."
fi
- name: Package extension zip
if: steps.version.outputs.exists == 'false'
run: |
VER="${{ steps.version.outputs.version }}"
STAGE="ZeroScript-extension-${VER}"
rm -rf "$STAGE"
cp -r zeroscript-extension "$STAGE"
# Dev-only parser test, not needed by end users.
rm -f "$STAGE/test-parser.js"
printf '%s\n' \
"ZeroScript Browser Extension v${VER}" \
"====================================" \
"" \
"Install:" \
" 1. Extract this zip." \
" 2. Open chrome://extensions (or edge://extensions)." \
" 3. Enable 'Developer mode' (top right)." \
" 4. Click 'Load unpacked' and select the '${STAGE}' folder." \
"" \
"Requires the ZeroScript Bridge to be running (desktop app or bridge.py)." \
> README.txt
zip -r "${STAGE}.zip" "$STAGE" README.txt
- name: Extract changelog section as release notes
id: notes
if: steps.version.outputs.exists == 'false'
run: |
VERSION="${{ steps.version.outputs.version }}"
# Menggunakan index() untuk exact string matching (menghindari bug regex)
# Skrip akan berhenti jika menemukan versi lain (## [x.x.x]) atau section statis
notes=$(awk -v ver="## [${VERSION}]" '
$0 == ver || index($0, ver" ") == 1 {
found=1
}
found && $0 ~ /^## \[/ && index($0, ver) != 1 {
exit
}
found && ($0 == "## Legacy Versions" || $0 == "## Versioning") {
exit
}
found {
print
}
' CHANGELOG.md)
if [ -z "$notes" ]; then
echo "::warning::No CHANGELOG.md section found for [${VERSION}] - using a fallback message."
notes="Release v${VERSION} of ZeroScript."
fi
printf '%s\n' "$notes" > /tmp/release-notes.md
- name: Create release
if: steps.version.outputs.exists == 'false'
env:
GH_TOKEN: ${{ github.token }}
run: |
# The extension zip needs no build, so it is attached immediately -
# desktop bundles follow from the build-desktop job below and land
# on the release a few minutes later.
gh release create "${{ steps.version.outputs.tag }}" \
"ZeroScript-extension-${{ steps.version.outputs.version }}.zip" \
--title "ZeroScript v${{ steps.version.outputs.version }}" \
--notes-file /tmp/release-notes.md \
${{ inputs.draft == true && '--draft' || '' }} \
${{ inputs.prerelease == true && '--prerelease' || '' }}
# ---------------------------------------------------------------------------
# Job 2: Build ZeroScript DESKTOP GUI (Tauri) on all three platforms.
#
# Flow per platform:
# 1. packaging/build.py --binaries-only -> PyInstaller bridge binaries
# 2. scripts/prepare-sidecars.mjs -> renamed into src-tauri/binaries
# with the host target-triple suffix Tauri requires for externalBin.
# 3. tauri build -> NSIS (Win) / DMG (mac) /
# AppImage + deb (Linux), bundling the bridge as a hidden sidecar.
#
# Dilewati jika release dibuat sebagai draft (konsisten dengan trigger
# `release: published` pada workflow lama, yang tidak fire untuk draft).
# ---------------------------------------------------------------------------
build-desktop:
name: ${{ matrix.os }}
needs: release
if: ${{ inputs.draft != true && needs.release.outputs.exists == 'false' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
artifact: zeroscript-gui-windows
- os: macos-latest
artifact: zeroscript-gui-macos
- os: ubuntu-latest
artifact: zeroscript-gui-linux
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Python (bridge sidecars)
uses: actions/setup-python@v7
with:
python-version: "3.11"
- name: Cache pip
uses: actions/cache@v4
with:
path: |
~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('packaging/requirements.txt') }}
- name: Set up Node (Tauri frontend)
uses: actions/setup-node@v7
with:
node-version: "20"
cache: npm
cache-dependency-path: zeroscript-desktop/package-lock.json
- name: Cache Node/npm
uses: actions/cache@v4
with:
path: |
~/.npm
zeroscript-desktop/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('zeroscript-desktop/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Linux system dependencies (WebKitGTK etc.)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libayatana-appindicator3-dev \
librsvg2-dev patchelf
- name: Build bridge sidecars (PyInstaller)
run: |
python -m pip install -r packaging/requirements.txt
python packaging/build.py --binaries-only
- name: Install frontend dependencies
working-directory: zeroscript-desktop
run: npm ci
- name: Prepare Tauri sidecars
working-directory: zeroscript-desktop
run: node scripts/prepare-sidecars.mjs
- name: Cache Cargo (Rust/tauri)
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
zeroscript-desktop/src-tauri/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build the Tauri app
working-directory: zeroscript-desktop
shell: bash
# Explicit per-OS bundles: Windows "all" would also build MSI (needs
# WiX) and Linux "all" includes rpm (needs rpmbuild) - neither is
# installed on the runners, so pin the targets we ship.
run: |
if [ "$RUNNER_OS" = "Windows" ]; then BUNDLES="nsis";
elif [ "$RUNNER_OS" = "macOS" ]; then BUNDLES="app,dmg";
else BUNDLES="deb,appimage"; fi
npx tauri build --bundles "$BUNDLES"
- name: Attach to release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ needs.release.outputs.tag }}
files: |
zeroscript-desktop/src-tauri/target/release/bundle/**/*.exe
zeroscript-desktop/src-tauri/target/release/bundle/**/*.msi
zeroscript-desktop/src-tauri/target/release/bundle/**/*.dmg
zeroscript-desktop/src-tauri/target/release/bundle/**/*.app
zeroscript-desktop/src-tauri/target/release/bundle/**/*.deb
zeroscript-desktop/src-tauri/target/release/bundle/**/*.AppImage