-
-
Notifications
You must be signed in to change notification settings - Fork 3
177 lines (153 loc) · 5.14 KB
/
build.yml
File metadata and controls
177 lines (153 loc) · 5.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
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
name: Build
on:
workflow_dispatch:
inputs:
node_version:
description: "Node.js Version"
required: false
default: "20.18.1"
electron_version:
description: "Electron Version"
required: false
default: "32.2.7"
env:
NODE_VERSION: ${{ inputs.node_version || '20.18.1' }}
ELECTRON_VERSION: ${{ inputs.electron_version || '32.2.7' }}
jobs:
compute-shasum:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Compute Sorted SHASUM
id: compute-shasum
run: |
# Generate SHASUM for all relevant files and sort them
chmod +x ./create-shasum.sh
./create-shasum.sh
# Output the current SHASUM for the environment
echo "shasum256save=$(cat sha256.txt)" >> $GITHUB_ENV
echo "shasum256save=$(cat sha256.txt)" >> "$GITHUB_OUTPUT"
- name: Check for Existing SHASUM
id: check-shasum
run: |
if [ -f ./.last-shasum ]; then
echo "Previous SHASUM exists."
echo "------"
cat sha256.txt
echo "------"
cat .last-shasum
echo "------"
diff sha256.txt ./.last-shasum > /dev/null || exit 1
else
echo "No previous SHASUM found."
exit 1
fi
outputs:
status: ${{ steps.check-shasum.outcome }}
shasum256save: ${{ steps.compute-shasum.outputs.shasum256save }}
build:
needs: compute-shasum
if: ${{ needs.compute-shasum.outputs.status == 'failure' }}
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm, windows-latest, macos-13, macOS-latest]
runs-on: ${{ matrix.os }}
steps:
- name: clone repository
uses: actions/checkout@v4
- name: install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: install dependencies
run: npm install
- name: run build script for windows
if: startsWith(matrix.os,'windows')
shell: powershell
timeout-minutes: 20
run: |
.\build-windows.ps1
- name: run build script for ubuntu
if: startsWith(matrix.os,'ubuntu')
shell: bash
run: |
chmod +x build-linux.sh
./build-linux.sh
- name: run build script for macOS
if: startsWith(matrix.os,'macOS')
shell: bash
run: |
chmod +x build-macos.sh
./build-macos.sh
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os }}
path: prebuilds/*
update-version-and-release:
needs: [compute-shasum, build]
if: ${{ needs.compute-shasum.outputs.status == 'failure' && needs.build.result == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Bump Version
id: bump_version
run: |
NEW_VERSION=$(date -u +"%Y%m.%d.%H%M%S")
echo "New version: $NEW_VERSION"
npm version $NEW_VERSION --no-git-tag-version
npm pkg fix
# Output new version for use in subsequent steps
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
- name: Commit Updated Version
run: |
echo "${{ needs.compute-shasum.outputs.shasum256save }}" > .last-shasum
git config user.name "github-actions"
git config user.email "actions@github.com"
git add package.json .last-shasum
git commit -m "chore: update version to ${{ env.new_version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push Changes
run: git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: prebuilds
pattern: release-*
merge-multiple: true
- name: Create GitHub Release
if: github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ env.new_version }}"
name: "Release v${{ env.new_version }}"
body: |
## Changes
- Automatic version bump to v${{ env.new_version }}.
- Automatic prebuilds for all platforms and architectures that use the Node.js in version ${{ env.NODE_VERSION }} and Electron in version ${{ env.ELECTRON_VERSION }}.
draft: false
prerelease: false
token: ${{ secrets.PAT_TOKEN }}
make_latest: true
files: |
prebuilds/*
.last-shasum
- name: Publish to npm
if: github.ref == 'refs/heads/main'
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org/"
- name: Publish Package
if: github.ref == 'refs/heads/main'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}