-
Notifications
You must be signed in to change notification settings - Fork 279
273 lines (244 loc) · 10.3 KB
/
Copy pathnightly.yml
File metadata and controls
273 lines (244 loc) · 10.3 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
261
262
263
264
265
266
267
268
269
270
271
272
273
# Nightly build of the `develop` branch.
#
# Every night it builds all platforms and publishes a single GitHub
# pre-release with a date+version tag and a changelog from the commits.
#
# - Runs on a schedule (~03:00 Spain: 01:00 UTC = 03:00 CEST / 02:00 CET).
# - Only builds if there are new commits in the last 24h (manual runs always
# build). Skipped days produce no release.
# - macOS is ad-hoc signed (no Apple certificate). Downloaded builds need
# `xattr -dr com.apple.quarantine` on first launch.
# - Nightly releases older than 15 days are deleted automatically.
#
# This does NOT change the per-PR behaviour: the "Code standardizer hook for
# PRs" (prettier/jshint) still validates PRs and never builds binaries. The
# per-platform build workflows (main*.yml) are manual (workflow_dispatch) for
# on-demand builds of any branch.
name: Nightly Build (develop)
on:
schedule:
- cron: '0 1 * * *' # 01:00 UTC ≈ 03:00 Spain (summer) / 02:00 (winter)
workflow_dispatch: # manual trigger (always builds)
permissions:
contents: write # create/delete releases and tags
jobs:
# ---------------------------------------------------------------------------
# Decide whether to build and compute the release metadata
# ---------------------------------------------------------------------------
check:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.gate.outputs.should_build }}
version: ${{ steps.meta.outputs.version }}
date: ${{ steps.meta.outputs.date }}
tag: ${{ steps.meta.outputs.tag }}
steps:
- uses: actions/checkout@v5
with:
ref: develop
fetch-depth: 0
- name: Decide whether to build (skip if no new commits)
id: gate
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "Manual run — building."
echo "should_build=true" >> "$GITHUB_OUTPUT"
elif [ -n "$(git log --since='24 hours ago' --oneline)" ]; then
echo "New commits in the last 24h — building."
echo "should_build=true" >> "$GITHUB_OUTPUT"
else
echo "No commits in the last 24h — skipping nightly."
echo "should_build=false" >> "$GITHUB_OUTPUT"
fi
- name: Compute version / date / tag
id: meta
run: |
version=$(jq -r '.version' package.json)
date=$(date -u +%Y%m%d)
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "date=${date}" >> "$GITHUB_OUTPUT"
echo "tag=v${version}-${date}" >> "$GITHUB_OUTPUT"
# ---------------------------------------------------------------------------
# Linux x64 + Windows x64 — also creates the release (with the changelog)
# ---------------------------------------------------------------------------
build-linwin:
needs: check
if: needs.check.outputs.should_build == 'true'
runs-on: ubuntu-22.04
env:
VERSION: ${{ needs.check.outputs.version }}
DATE: ${{ needs.check.outputs.date }}
TAG: ${{ needs.check.outputs.tag }}
NW_FLAVOR: sdk
steps:
- uses: actions/checkout@v5
with:
ref: develop
fetch-depth: 0
- uses: actions/setup-node@v5
with:
node-version: '23.3.0'
- name: Install npm dependencies
run: npm install --legacy-peer-deps
- name: Install NSIS + libfuse2
run: |
sudo add-apt-repository -y universe
sudo apt-get update
sudo apt-get install -y nsis libfuse2
- name: Build Windows
run: |
export DISPLAY=:0.0
npm run buildWindows
- name: Stage Windows artifacts
run: |
# `grunt dist` runs clean:dist on every build, wiping the WHOLE dist/
# folder. Move the Windows artifacts out (to nightly/) before building
# Linux, otherwise the Linux build deletes them.
mkdir -p nightly
mv dist/icestudio-*-win64.exe "nightly/icestudio-${VERSION}-${DATE}-win64.exe"
mv dist/icestudio-*-win64.zip "nightly/icestudio-${VERSION}-${DATE}-win64.zip"
- name: Build Linux
run: |
export DISPLAY=:0.0
# appimagetool appends $VERSION to the AppImage filename when it is set
# (-> Icestudio-$VERSION-x86_64.AppImage), which breaks
# scripts/appImageBuild.sh (it renames the expected, unversioned
# Icestudio-x86_64.AppImage). Unset it so the build produces the
# correct icestudio-<build-id>-linux64.AppImage.
unset VERSION
npm run buildLinux64
- name: Stage Linux artifacts
run: |
mv dist/icestudio-*-linux64.AppImage "nightly/icestudio-${VERSION}-${DATE}-linux64.AppImage"
mv dist/icestudio-*-linux64.zip "nightly/icestudio-${VERSION}-${DATE}-linux64.zip"
- name: Generate changelog
run: |
prev=$(git tag -l --sort=-creatordate 'v*-????????' | head -1)
if [ -n "$prev" ]; then range="$prev..HEAD"; else range="HEAD~30..HEAD"; fi
{
echo "Automated nightly build of \`develop\` (${DATE})."
echo ""
echo "macOS build is ad-hoc signed (not notarized): after downloading,"
echo "run \`xattr -dr com.apple.quarantine /Applications/icestudio.app\`."
echo ""
echo "### Changes${prev:+ since $prev}"
echo ""
git log $range --no-merges --pretty='- %s (%h)' 2>/dev/null || echo "- (no changelog available)"
} > changelog.md
cat changelog.md
- name: Create nightly release + upload Linux/Windows
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ env.TAG }}
name: Nightly ${{ env.VERSION }} — ${{ env.DATE }}
prerelease: false
make_latest: false
target_commitish: develop
body_path: changelog.md
files: |
nightly/icestudio-${{ env.VERSION }}-${{ env.DATE }}-win64.exe
nightly/icestudio-${{ env.VERSION }}-${{ env.DATE }}-win64.zip
nightly/icestudio-${{ env.VERSION }}-${{ env.DATE }}-linux64.AppImage
nightly/icestudio-${{ env.VERSION }}-${{ env.DATE }}-linux64.zip
# ---------------------------------------------------------------------------
# macOS arm64 (ad-hoc signed)
# ---------------------------------------------------------------------------
build-macos:
needs: [check, build-linwin]
if: needs.check.outputs.should_build == 'true'
runs-on: macos-15
env:
VERSION: ${{ needs.check.outputs.version }}
DATE: ${{ needs.check.outputs.date }}
TAG: ${{ needs.check.outputs.tag }}
NW_FLAVOR: sdk
CODESIGN_ID: '-'
steps:
- uses: actions/checkout@v5
with:
ref: develop
- uses: actions/setup-node@v5
with:
node-version: '23.3.0'
- name: Install npm dependencies
run: |
# Merge macOS-only deps (grunt-appdmg, fs-xattr) into "dependencies"
# so npm installs them. A plain rename would create a duplicate
# "dependencies" key (package.json already has an empty one) and npm
# keeps the last, empty one -> grunt-appdmg was never installed.
node -e "const fs=require('fs');const p=JSON.parse(fs.readFileSync('package.json'));p.dependencies=Object.assign({},p.dependencies,p.darwinDependencies);delete p.darwinDependencies;fs.writeFileSync('package.json',JSON.stringify(p,null,2))"
npm install --legacy-peer-deps
- name: Build macOS arm64 (ad-hoc signed)
run: |
npm run buildOSXARM64
ls dist/
- name: Rename artifact to nightly name
run: mv dist/icestudio-*-osxarm64.dmg "dist/icestudio-${VERSION}-${DATE}-osxarm64.dmg"
- name: Upload macOS to release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ env.TAG }}
prerelease: false
make_latest: false
target_commitish: develop
files: dist/icestudio-${{ env.VERSION }}-${{ env.DATE }}-osxarm64.dmg
# ---------------------------------------------------------------------------
# Linux ARM (aarch64)
# ---------------------------------------------------------------------------
build-arm:
needs: [check, build-linwin]
if: needs.check.outputs.should_build == 'true'
runs-on: ubuntu-24.04
env:
VERSION: ${{ needs.check.outputs.version }}
DATE: ${{ needs.check.outputs.date }}
TAG: ${{ needs.check.outputs.tag }}
NW_FLAVOR: sdk
steps:
- uses: actions/checkout@v5
with:
ref: develop
- uses: actions/setup-node@v5
with:
node-version: '23.3.0'
- name: Install npm dependencies
run: npm install --legacy-peer-deps
- name: Build Aarch64
run: |
export DISPLAY=:0.0
npm run buildAarch64
- name: Rename artifact to nightly name
run: mv dist/icestudio-*-aarch64.zip "dist/icestudio-${VERSION}-${DATE}-aarch64.zip"
- name: Upload Aarch64 to release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ env.TAG }}
prerelease: false
make_latest: false
target_commitish: develop
files: dist/icestudio-${{ env.VERSION }}-${{ env.DATE }}-aarch64.zip
# ---------------------------------------------------------------------------
# Delete nightly releases (and their tags) older than 15 days
# ---------------------------------------------------------------------------
cleanup:
needs: [check, build-linwin, build-macos, build-arm]
if: always() && needs.check.outputs.should_build == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
ref: develop
- name: Delete nightlies older than 15 days
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cutoff=$(date -u -d '15 days ago' +%Y%m%d)
echo "Deleting nightlies with date < ${cutoff}"
gh release list --limit 200 --json tagName --jq '.[].tagName' \
| grep -E '^v.*-[0-9]{8}$' | while read -r tag; do
d=$(echo "$tag" | grep -oE '[0-9]{8}$')
if [ "$d" -lt "$cutoff" ]; then
echo "Deleting old nightly: $tag"
gh release delete "$tag" --yes --cleanup-tag || true
fi
done