Skip to content

Commit a4c46ac

Browse files
committed
Merge branch 'dev' of https://github.com/ExquisiteCore/Blog into dev
2 parents 41b4d9a + 5ecf158 commit a4c46ac

1 file changed

Lines changed: 54 additions & 17 deletions

File tree

.github/workflows/backend.yml

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches: ["dev"]
66
pull_request:
77
branches: ["dev"]
8+
release:
9+
types:
10+
- published # 当发布版本时触发
811

912
env:
1013
CARGO_TERM_COLOR: always
@@ -48,7 +51,6 @@ jobs:
4851

4952
- name: Prepare SQLx metadata
5053
run: |
51-
mkdir -p backend/.sqlx
5254
cd backend
5355
cargo sqlx prepare -- --tests
5456
env:
@@ -66,11 +68,16 @@ jobs:
6668
fail-fast: false
6769
matrix:
6870
target:
69-
- name: Linux
71+
- name: Linux x86_64
7072
os: ubuntu-latest
7173
target: x86_64-unknown-linux-gnu
7274
bin: backend
7375
asset_name: backend-linux-amd64
76+
- name: Linux ARM64
77+
os: ubuntu-latest
78+
target: aarch64-unknown-linux-gnu
79+
bin: backend
80+
asset_name: backend-linux-arm64
7481
- name: Windows
7582
os: windows-latest
7683
target: x86_64-pc-windows-msvc
@@ -110,7 +117,6 @@ jobs:
110117

111118
- name: Prepare SQLx metadata
112119
run: |
113-
mkdir -p backend/.sqlx
114120
cd backend
115121
cargo sqlx prepare -- --tests
116122
env:
@@ -136,25 +142,56 @@ jobs:
136142
path: backend/release/${{ matrix.target.asset_name }}
137143
if-no-files-found: error
138144

139-
create-release:
140-
name: Create Release
141-
needs: build
145+
update-release-notes:
146+
permissions:
147+
contents: write
142148
runs-on: ubuntu-latest
143-
if: startsWith(github.ref, 'refs/tags/')
144149
steps:
145150
- uses: actions/checkout@v4
146151

147-
- name: Download all artifacts
148-
uses: actions/download-artifact@v4
152+
- name: Extract release notes
153+
id: extract-release-notes
154+
uses: ffurrer2/extract-release-notes@v2
155+
156+
- uses: softprops/action-gh-release@v2
149157
with:
150-
path: artifacts
158+
body: |-
159+
${{ steps.extract-release-notes.outputs.release_notes }}
160+
| File | SHA256 |
161+
| ---- | ------ |
162+
163+
upload-to-release:
164+
needs:
165+
- build
166+
- update-release-notes
167+
permissions:
168+
contents: write
169+
runs-on: ubuntu-latest
170+
strategy:
171+
matrix:
172+
mode:
173+
- debug
174+
- release
175+
steps:
176+
- uses: actions/checkout@v4
177+
178+
- uses: actions/download-artifact@v4
179+
with:
180+
name: ${{ matrix.target.asset_name }}
181+
path: artifact
182+
183+
- run: |
184+
zip -r ../${{ matrix.asset_name }} *
185+
working-directory: artifact
151186
152-
- name: List downloaded artifacts (for debugging)
153-
run: ls -R artifacts
187+
- id: calculate-sha256
188+
run: |
189+
echo sha256=$(sha256sum ${{ matrix.asset_name }} | awk '{print $1}') >> $GITHUB_OUTPUT
154190
155-
- name: Create GitHub Release
156-
uses: softprops/action-gh-release@v1
191+
- uses: softprops/action-gh-release@v2
157192
with:
158-
files: artifacts/**
159-
draft: false
160-
prerelease: false
193+
append_body: true
194+
body: |-
195+
| ${{ matrix.asset_name }} | ${{ steps.calculate-sha256.outputs.sha256 }} |
196+
files: |
197+
${{ matrix.asset_name }}

0 commit comments

Comments
 (0)