-
-
Notifications
You must be signed in to change notification settings - Fork 106
169 lines (143 loc) · 4.65 KB
/
Copy pathrelease.yml
File metadata and controls
169 lines (143 loc) · 4.65 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: 'Release Version (e.g. v1.0.0)'
required: false
default: 'v1.0.0'
release_type:
type: choice
description: 'Build Type (Release or Demo)'
required: true
default: 'release'
options:
- 'release'
- 'prelease'
jobs:
prepare:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
commit_sha: ${{ steps.set_sha.outputs.commit_sha }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN || secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Install Node v20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Update version and artifact name
if: github.event_name == 'workflow_dispatch'
run: |
VERSION="${{ github.event.inputs.version }}"
RELEASE_TYPE="${{ github.event.inputs.release_type }}"
CLEAN_VERSION="${VERSION#v}"
if [ -n "$CLEAN_VERSION" ]; then
npm version "$CLEAN_VERSION" --no-git-tag-version --allow-same-version
fi
if [ "$RELEASE_TYPE" = "prelease" ]; then
node -e "
const fs = require('fs');
let content = fs.readFileSync('electron-builder.yml', 'utf8');
content = content.replace(/artifactName:\s*['\"].*?['\"]/, \"artifactName: '\${productName}-prelease-\${os}-\${arch}-\${version}.\${ext}'\");
fs.writeFileSync('electron-builder.yml', content, 'utf8');
"
fi
- name: Commit, pull and push changes
if: github.event_name == 'workflow_dispatch'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json electron-builder.yml
if [ -f package-lock.json ]; then
git add package-lock.json
fi
if ! git diff --staged --quiet; then
git commit -m "chore(release): bump version to ${{ github.event.inputs.version }} [${{ github.event.inputs.release_type }}]"
git pull --rebase origin ${{ github.ref_name }}
git push origin HEAD:${{ github.ref_name }}
fi
- name: Set output commit SHA
id: set_sha
run: echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
publish_on_linux:
needs: [prepare]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.commit_sha || github.ref }}
- name: Install Node v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm install --force
- name: Install electron-builder
run: npm i electron-builder -g
- name: Publish
env:
GH_TOKEN: ${{ secrets.TOKEN }}
run: npm run publish:linux
publish_on_win:
needs: [prepare]
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.commit_sha || github.ref }}
- name: Install Node v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm install --force
- name: Install electron-builder
run: npm i electron-builder -g
- name: Publish
env:
GH_TOKEN: ${{ secrets.TOKEN }}
run: npm run publish:win
publish_on_macos:
needs: [prepare]
runs-on: macOS-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.commit_sha || github.ref }}
- name: Install Node v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install Python
run: brew install python@3.11
- name: "Install Python setuptools"
run: brew install python-setuptools
- name: Install Build Tools
run: |
brew install libtool automake autoconf
sudo xcode-select --reset
- name: Update node-gyp
run: npm install -g node-gyp
- name: Install dependencies
run: npm install --force
- name: Install electron-builder
run: npm i electron-builder -g
- name: Publish
env:
GH_TOKEN: ${{ secrets.TOKEN }}
run: npm run publish:mac