Skip to content

Commit afefac9

Browse files
author
linyuan.yang
committed
release
1 parent 7101897 commit afefac9

1 file changed

Lines changed: 49 additions & 17 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ jobs:
5454
path: |
5555
~/.cargo/registry
5656
~/.cargo/git
57-
src-tauri/target
58-
key: ${{ matrix.platform }}-cargo-${{ hashFiles('src-tauri/Cargo.lock') }}
57+
packages/app/src-tauri/target
58+
key: ${{ matrix.platform }}-${{ matrix.rust-target || 'default' }}-cargo-${{ hashFiles('packages/app/src-tauri/Cargo.lock') }}
5959
restore-keys: |
60+
${{ matrix.platform }}-${{ matrix.rust-target || 'default' }}-cargo-
6061
${{ matrix.platform }}-cargo-
6162
6263
- name: Install Linux deps
@@ -71,7 +72,11 @@ jobs:
7172
id: notes
7273
shell: bash
7374
run: |
74-
VERSION="${GITHUB_REF_NAME#v}"
75+
if [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then
76+
VERSION="${GITHUB_REF_NAME#v}"
77+
else
78+
VERSION="$(node -p "require('./package.json').version")"
79+
fi
7580
BODY=$(awk -v v="$VERSION" '
7681
$1 == "##" && $2 == v { capture=1; next }
7782
capture && $1 == "##" { exit }
@@ -101,20 +106,38 @@ jobs:
101106

102107
publish-manifest:
103108
needs: release-desktop
104-
if: ${{ !cancelled() }}
109+
if: ${{ needs.release-desktop.result == 'success' }}
105110
runs-on: ubuntu-latest
106111
steps:
107112
- uses: actions/checkout@v5
108113

114+
- uses: actions/setup-node@v5
115+
with:
116+
node-version: 24
117+
118+
- name: Resolve release tag
119+
id: release
120+
shell: bash
121+
run: |
122+
if [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then
123+
TAG="${GITHUB_REF_NAME}"
124+
VERSION="${TAG#v}"
125+
else
126+
VERSION="$(node -p "require('./package.json').version")"
127+
TAG="v${VERSION}"
128+
fi
129+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
130+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
131+
109132
- name: Force release body from CHANGELOG
110-
if: github.event_name == 'push'
111133
env:
112134
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113135
REPO: ${{ github.repository }}
114-
TAG: ${{ github.ref_name }}
136+
TAG: ${{ steps.release.outputs.tag }}
137+
RELEASE_VERSION: ${{ steps.release.outputs.version }}
115138
shell: bash
116139
run: |
117-
VERSION="${TAG#v}"
140+
VERSION="$RELEASE_VERSION"
118141
BODY=$(awk -v v="$VERSION" '
119142
$1 == "##" && $2 == v { capture=1; next }
120143
capture && $1 == "##" { exit }
@@ -132,15 +155,20 @@ jobs:
132155
env:
133156
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134157
REPO: ${{ github.repository }}
135-
TAG: ${{ github.ref_name }}
158+
TAG: ${{ steps.release.outputs.tag }}
159+
ASSET_VERSION: ${{ steps.release.outputs.version }}
136160
run: |
137161
gh api "/repos/$REPO/releases/tags/$TAG" --jq '.assets[] | "\(.id)\t\(.name)"' |
138162
while IFS=$'\t' read -r id name; do
139163
new=$(printf '%s' "$name" | sed -E \
140-
-e 's/^(sbox_[0-9][0-9.]*)_(aarch64|x64)\.dmg/\1_macos_\2.dmg/' \
141-
-e 's/^(sbox_[0-9][0-9.]*)_(amd64)\.(AppImage|deb)/\1_linux_\2.\3/' \
142-
-e 's/^(sbox_[0-9][0-9.]*)_(x64|arm64)-setup\.exe/\1_windows_\2-setup.exe/' \
143-
-e 's/^(sbox)_(aarch64|x64)\.app\.tar\.gz/\1_macos_\2.app.tar.gz/')
164+
-e "s#^sbox_[0-9][0-9.]*_aarch64\.dmg#sbox_${ASSET_VERSION}_macos_arm64.dmg#" \
165+
-e "s#^sbox_[0-9][0-9.]*_x64\.dmg#sbox_${ASSET_VERSION}_macos_x64.dmg#" \
166+
-e "s#^sbox_aarch64\.app\.tar\.gz#sbox_${ASSET_VERSION}_macos_arm64.app.tar.gz#" \
167+
-e "s#^sbox_x64\.app\.tar\.gz#sbox_${ASSET_VERSION}_macos_x64.app.tar.gz#" \
168+
-e "s#^sbox_[0-9][0-9.]*_amd64\.(AppImage|deb)#sbox_${ASSET_VERSION}_linux_x64.\1#" \
169+
-e "s#^sbox_[0-9][0-9.]*_arm64\.(AppImage|deb)#sbox_${ASSET_VERSION}_linux_arm64.\1#" \
170+
-e "s#^sbox_[0-9][0-9.]*_x64-setup\.exe#sbox_${ASSET_VERSION}_windows_x64.exe#" \
171+
-e "s#^sbox_[0-9][0-9.]*_arm64-setup\.exe#sbox_${ASSET_VERSION}_windows_arm64.exe#")
144172
if [ "$new" != "$name" ]; then
145173
echo "rename: $name -> $new"
146174
gh api -X PATCH "/repos/$REPO/releases/assets/$id" -f name="$new" >/dev/null
@@ -151,18 +179,22 @@ jobs:
151179
env:
152180
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
153181
REPO: ${{ github.repository }}
154-
TAG: ${{ github.ref_name }}
182+
TAG: ${{ steps.release.outputs.tag }}
183+
ASSET_VERSION: ${{ steps.release.outputs.version }}
155184
run: |
156185
if ! gh release download "$TAG" -R "$REPO" -p "latest.json" -O latest.json; then
157186
echo "::error::latest.json not found on release $TAG — no platform produced an updater manifest"
158187
exit 1
159188
fi
160189
# 上一步已重命名更新载荷文件,latest.json 里的 URL 需同步改写,否则更新器会 404。
161-
# latest.json 只含 tar.gz / setup.exe / AppImage 三类载荷 URL;base64 签名字段不含这些模式,g 全局替换安全。
190+
# latest.json 只含 app.tar.gz / setup.exe / AppImage 三类载荷 URL;base64 签名字段不含这些模式,g 全局替换安全。
162191
sed -i -E \
163-
-e 's#(sbox)_(aarch64|x64)\.app\.tar\.gz#\1_macos_\2.app.tar.gz#g' \
164-
-e 's#(sbox_[0-9][0-9.]*)_(x64|arm64)-setup\.exe#\1_windows_\2-setup.exe#g' \
165-
-e 's#(sbox_[0-9][0-9.]*)_(amd64)\.AppImage#\1_linux_\2.AppImage#g' \
192+
-e "s#sbox_aarch64\.app\.tar\.gz#sbox_${ASSET_VERSION}_macos_arm64.app.tar.gz#g" \
193+
-e "s#sbox_x64\.app\.tar\.gz#sbox_${ASSET_VERSION}_macos_x64.app.tar.gz#g" \
194+
-e "s#sbox_[0-9][0-9.]*_x64-setup\.exe#sbox_${ASSET_VERSION}_windows_x64.exe#g" \
195+
-e "s#sbox_[0-9][0-9.]*_arm64-setup\.exe#sbox_${ASSET_VERSION}_windows_arm64.exe#g" \
196+
-e "s#sbox_[0-9][0-9.]*_amd64\.AppImage#sbox_${ASSET_VERSION}_linux_x64.AppImage#g" \
197+
-e "s#sbox_[0-9][0-9.]*_arm64\.AppImage#sbox_${ASSET_VERSION}_linux_arm64.AppImage#g" \
166198
latest.json
167199
gh release view updater -R "$REPO" >/dev/null 2>&1 || \
168200
gh release create updater -R "$REPO" \

0 commit comments

Comments
 (0)