-
Notifications
You must be signed in to change notification settings - Fork 283
82 lines (69 loc) · 2.14 KB
/
release-assets.yml
File metadata and controls
82 lines (69 loc) · 2.14 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
name: build-and-release
on:
push:
tags:
- 'v*'
env:
NODE_VERSION: '22' # 使用 Node.js 22 版本
jobs:
build-and-release:
runs-on: ubuntu-latest
permissions:
contents: write # 需要写入权限来创建发布
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取所有历史记录
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install 7zip
run: |
sudo apt-get update
sudo apt-get install -y p7zip-full
- name: Install dependencies
run: npm ci
- name: Run packageJS script
run: npm run packageJS
- name: Run packageJS-green script
run: npm run packageJS-green
- name: Find generated 7z files
run: |
# 在上级目录查找生成的 7z 文件
cd ..
echo "Generated files:"
ls -la *.7z || echo "No 7z files found"
# 将文件列表保存到环境变量中
echo "FILES=$(ls *.7z 2>/dev/null | tr '\n' ' ')" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false
- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# 切换到上级目录
cd ..
# 上传所有找到的 7z 文件
for file in $FILES; do
echo "Uploading $file..."
curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$file" \
"${{ steps.create_release.outputs.upload_url }}?name=$file"
echo "Uploaded $file"
done
- name: Verify upload
run: |
echo "Uploaded files: $FILES"