-
Notifications
You must be signed in to change notification settings - Fork 2
140 lines (138 loc) · 5.03 KB
/
release.yml
File metadata and controls
140 lines (138 loc) · 5.03 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
name: Release
on:
push:
tags:
- '*'
jobs:
build-artifacts:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-15-intel
platform: darwin
arch: x64
artifact_name: darwin-x64
- os: macos-latest
platform: darwin
arch: arm64
artifact_name: darwin-arm64
- os: windows-latest
platform: win32
arch: x64
artifact_name: win32-x64
- os: windows-11-arm
platform: win32
arch: arm64
artifact_name: win32-arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Cache Node Modules
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ matrix.os }}-${{ matrix.platform }}-${{ matrix.arch }}-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
shell: bash
run: |
if [ -d "node_modules" ]; then
echo "node_modules exists"
else
npm cache clean --force
npm ci --force
fi
- name: Build application
run: npm run build
- name: Build for ${{ matrix.platform }}-${{ matrix.arch }}
run: npm run pack
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: List build artifacts
shell: bash
run: |
echo "Build artifacts:"
if echo "${{ matrix.os }}" | grep -qi "windows"; then
powershell -Command "if (-Not (Test-Path 'release')) { echo 'No release directory found' }"
powershell -Command "if (Test-Path 'release\\*.exe') { Get-ChildItem 'release\\*.exe' -Recurse } else { echo 'No .exe files found' }"
powershell -Command "if (Test-Path 'release\\*.zip') { Get-ChildItem 'release\\*.zip' -Recurse } else { echo 'No .zip files found' }"
else
ls -la release/ || echo "No release directory found"
find release/ -type f \( -name "*.dmg" -o -name "*.zip" -o -name "*.AppImage" \) || echo "No build artifacts found"
fi
- name: Upload artifacts to GitHub
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}-${{ github.ref_name }}
path: |
release/*.dmg
release/*.exe
release/*.zip
release/*.AppImage
retention-days: 30
- name: Upload artifacts to COS
run: node scripts/upload-artifacts-to-cos.js ${{ github.ref_name }}
env:
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
COS_DOMAIN: ${{ secrets.COS_DOMAIN }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_REGION: ${{ secrets.COS_REGION }}
create-release:
needs: build-artifacts
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get tag information
id: tag_info
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
TAG_MESSAGE=$(git tag -l --format='%(contents)' ${{ github.ref_name }})
if [ -z "$TAG_MESSAGE" ]; then
TAG_MESSAGE="No description provided for this release."
fi
echo "tag_message<<EOF" >> $GITHUB_OUTPUT
echo "$TAG_MESSAGE" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "TAG_MESSAGE: $TAG_MESSAGE"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
- name: List artifacts
run: tree -a artifacts/
- name: Install dependencies
run: npm run ci:create-release
- name: Upload version index to COS
run: node scripts/upload-version-index-to-cos.js ${{ github.ref_name }}
env:
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
COS_DOMAIN: ${{ secrets.COS_DOMAIN }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_REGION: ${{ secrets.COS_REGION }}
TZ: Asia/Shanghai
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
files: |
artifacts/darwin-x64-${{ github.ref_name }}/*
artifacts/darwin-arm64-${{ github.ref_name }}/*
artifacts/win32-x64-${{ github.ref_name }}/*
artifacts/win32-arm64-${{ github.ref_name }}/*
body: |
${{ steps.tag_info.outputs.tag_message }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}