forked from OpenCloudGaming/OpenNOW
-
Notifications
You must be signed in to change notification settings - Fork 0
260 lines (225 loc) · 7.88 KB
/
release.yml
File metadata and controls
260 lines (225 loc) · 7.88 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
name: release
on:
workflow_dispatch:
inputs:
version:
description: Version to release, e.g. 1.2.3 or v1.2.3
required: true
type: string
push:
tags:
- "v*.*.*"
- "opennow-stable-v*.*.*"
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions:
contents: read
jobs:
preflight:
name: preflight
runs-on: ubuntu-24.04
outputs:
version: ${{ steps.release.outputs.version }}
prerelease: ${{ steps.release.outputs.prerelease }}
make_latest: ${{ steps.release.outputs.make_latest }}
release_tag: ${{ steps.release.outputs.release_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: opennow-stable/package-lock.json
- name: Install dependencies
working-directory: opennow-stable
run: npm ci --prefer-offline --no-audit --progress=false
- name: Typecheck
working-directory: opennow-stable
run: npm run typecheck --if-present
- name: Resolve release metadata
id: release
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
REF_NAME: ${{ github.ref_name }}
EVENT_NAME: ${{ github.event_name }}
run: |
raw="${INPUT_VERSION:-$REF_NAME}"
case "$raw" in
opennow-stable-v*) version="${raw#opennow-stable-v}" ;;
v*) version="${raw#v}" ;;
*) version="$raw" ;;
esac
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid semver version: $raw" >&2
exit 1
fi
prerelease=false
if [[ "$version" == *-* ]]; then
prerelease=true
fi
make_latest=true
if [[ "$prerelease" == true ]]; then
make_latest=false
fi
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
release_tag="v${version}"
else
release_tag="$raw"
fi
{
echo "version=$version"
echo "prerelease=$prerelease"
echo "make_latest=$make_latest"
echo "release_tag=$release_tag"
} >> "$GITHUB_OUTPUT"
build:
name: ${{ matrix.label }}
runs-on: ${{ matrix.os }}
needs: preflight
strategy:
fail-fast: false
matrix:
include:
- label: windows
os: blacksmith-4vcpu-windows-2025
builder_args: "--win nsis portable"
- label: macos-x64
os: macos-latest
builder_args: "--mac dmg zip --x64"
- label: macos-arm64
os: macos-latest
builder_args: "--mac dmg zip --arm64"
- label: linux-x64
os: blacksmith-4vcpu-ubuntu-2404
builder_args: "--linux AppImage deb --x64"
- label: linux-arm64
os: blacksmith-4vcpu-ubuntu-2404-arm
builder_args: "--linux AppImage deb --arm64"
defaults:
run:
working-directory: opennow-stable
env:
CSC_IDENTITY_AUTO_DISCOVERY: "false"
ELECTRON_CACHE: ${{ github.workspace }}/.cache/electron
ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder
npm_config_audit: "false"
npm_config_fund: "false"
RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
USE_SYSTEM_FPM: ${{ matrix.label == 'linux-arm64' && 'true' || 'false' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: "**/package-lock.json"
- name: Cache Electron binaries
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/.cache/electron
${{ github.workspace }}/.cache/electron-builder
key: ${{ runner.os }}-electron-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-electron-
- name: Install Linux packaging tools
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y fakeroot rpm
- name: Install FPM for arm64 deb builds
if: matrix.label == 'linux-arm64'
run: sudo apt-get install -y ruby ruby-dev build-essential && sudo gem install fpm
- name: Install dependencies
run: npm ci --prefer-offline --no-audit --progress=false
- name: Update package version
run: node -e "const fs=require('fs'); const path='package.json'; const pkg=JSON.parse(fs.readFileSync(path,'utf8')); pkg.version=process.env.RELEASE_VERSION; fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n');"
- name: Build app bundles
run: npm run build
- name: Package installers
run: npx electron-builder --publish never ${{ matrix.builder_args }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: opennow-stable-${{ matrix.label }}
path: |
opennow-stable/dist-release/*.exe
opennow-stable/dist-release/*.dmg
opennow-stable/dist-release/*.zip
opennow-stable/dist-release/*.AppImage
opennow-stable/dist-release/*.deb
if-no-files-found: error
release:
name: publish-release
runs-on: blacksmith-2vcpu-ubuntu-2404
needs:
- preflight
- build
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
merge-multiple: true
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.preflight.outputs.release_tag }}
name: OpenNOW v${{ needs.preflight.outputs.version }}
prerelease: ${{ needs.preflight.outputs.prerelease }}
make_latest: ${{ needs.preflight.outputs.make_latest }}
generate_release_notes: true
files: release-artifacts/**/*
finalize:
name: finalize-version-bump
runs-on: blacksmith-2vcpu-ubuntu-2404
needs:
- preflight
- release
permissions:
contents: write
steps:
- name: Resolve release branch
id: branch
shell: bash
env:
REF_TYPE: ${{ github.ref_type }}
REF_NAME: ${{ github.ref_name }}
run: |
if [[ "$REF_TYPE" == "branch" ]]; then
branch="$REF_NAME"
else
branch="dev"
fi
echo "branch=$branch" >> "$GITHUB_OUTPUT"
- name: Checkout release branch
uses: actions/checkout@v4
with:
ref: ${{ steps.branch.outputs.branch }}
fetch-depth: 0
token: ${{ secrets.RELEASE_PUSH_TOKEN || secrets.GITHUB_TOKEN }}
- name: Update package version
working-directory: opennow-stable
env:
RELEASE_VERSION: ${{ needs.preflight.outputs.version }}
run: node -e "const fs=require('fs'); const path='package.json'; const pkg=JSON.parse(fs.readFileSync(path,'utf8')); pkg.version=process.env.RELEASE_VERSION; fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n');"
- name: Commit and push
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add opennow-stable/package.json
if git diff --cached --quiet; then
echo "No version bump changes to commit."
exit 0
fi
git commit -m "chore(release): prepare v${{ needs.preflight.outputs.version }}"
git push origin HEAD:${{ steps.branch.outputs.branch }}