-
Notifications
You must be signed in to change notification settings - Fork 18
326 lines (282 loc) · 11.4 KB
/
release.yml
File metadata and controls
326 lines (282 loc) · 11.4 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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
name: Release
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
setup:
runs-on: ubuntu-latest
outputs:
build_hash: ${{ steps.simba-url.outputs.buildHash }}
base_url: ${{ steps.simba-url.outputs.baseUrl }}
test_files: ${{ steps.list-test-files.outputs.testFiles }}
plugins_hash: ${{ steps.wasp-plugins-hash.outputs.sha }}
assets_hash: ${{ steps.wasp-assets-hash.outputs.sha }}
steps:
- name: Fetch Simba 2 download URL
id: simba-url
run: |
README_URL="https://raw.githubusercontent.com/Villavu/Simba-Build-Archive/refs/heads/main/README.md"
README=$(curl -sSL "$README_URL")
FULL_URL=$(echo "$README" | grep -oP '\[Win64\]\(/[^)]*simba2000[^)]*Win64\.zip\?raw=true\)' | head -n1 | sed 's/^\[Win64\](//; s/)$//')
if [[ -z "$FULL_URL" ]]; then
echo "Error: Could not find simba2000 Win64 URL in README"
exit 1
fi
FULL_URL="https://raw.githubusercontent.com/Villavu/Simba-Build-Archive/refs/heads/main${FULL_URL}"
if [[ $FULL_URL =~ ([a-zA-Z0-9]{10})/Win64\.zip ]]; then
BUILD_HASH="${BASH_REMATCH[1]}"
else
echo "Error: Could not extract build hash from $FULL_URL"
exit 1
fi
BASE_URL="${FULL_URL%Win64.zip*}"
echo "baseUrl=$BASE_URL" >> $GITHUB_OUTPUT
echo "buildHash=$BUILD_HASH" >> $GITHUB_OUTPUT
echo "fullUrl=$FULL_URL" >> $GITHUB_OUTPUT
echo "FULL_URL=$FULL_URL"
echo "BUILD_HASH=$BUILD_HASH"
echo "BASE_URL=$BASE_URL"
- name: Checkout WaspLib
uses: actions/checkout@v5
with:
path: ./Includes/WaspLib
- name: Upload WaspLib repo
uses: actions/upload-artifact@v6
with:
name: wasplib
path: ./Includes/WaspLib
- name: List .simba files
id: list-test-files
run: |
cd ./Includes/WaspLib/tests
FILES=$(find . -maxdepth 1 -name '*.simba' -printf '%f\n' | jq -R . | jq -s -c .)
echo "Files found: $FILES"
echo "testFiles=$FILES" >> $GITHUB_OUTPUT
- name: Get wasp-plugins hash
id: wasp-plugins-hash
run: |
SHA=$(git ls-remote https://github.com/WaspScripts/wasp-plugins.git HEAD | awk '{ print $1 }')
echo "sha=$SHA" >> $GITHUB_OUTPUT
- name: Get wasp-assets hash
id: wasp-assets-hash
run: |
SHA=$(git ls-remote https://github.com/WaspScripts/wasp-assets.git HEAD | awk '{ print $1 }')
echo "sha=$SHA" >> $GITHUB_OUTPUT
tests:
needs: setup
runs-on: windows-latest
strategy:
fail-fast: true
matrix:
arch: [Win32, Win64]
file: ${{ fromJSON(needs.setup.outputs.test_files) }}
steps:
#Simba
- name: Check Simba64 cache
uses: actions/cache@v4
id: simba-cache
with:
path: |
./Simba-${{ matrix.arch }}.exe
key: simba-cache-${{ matrix.arch }}-${{ needs.setup.outputs.build_hash }}
enableCrossOsArchive: true
- name: Download Simba 2.0 (${{ matrix.arch }})
if: steps.simba-cache.outputs.cache-hit != 'true'
run: |
$baseUrl = "${{ needs.setup.outputs.base_url }}"
$downloadUrl = "$baseUrl" + "${{ matrix.arch }}.zip?raw=true"
Write-Output "Download ${{ matrix.arch }} URL: $downloadUrl"
$outputFile = ".\download.zip"
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile
Expand-Archive -Path $outputFile -DestinationPath . -Force
Remove-Item -Path $outputFile -Force
#Plugins
- name: Cache wasp-plugins
uses: actions/cache@v4
id: wasp-plugins-cache
with:
path: ./Plugins/wasp-plugins
key: wasp-plugins-${{ needs.setup.outputs.plugins_hash }}
- name: Checkout wasp-plugins
if: steps.wasp-plugins-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v5
with:
repository: WaspScripts/wasp-plugins
path: ./Plugins/wasp-plugins
#Assets
- name: Cache wasp-assets
uses: actions/cache@v4
id: wasp-assets-cache
with:
path: ./Data/Assets
key: wasp-assets-${{ needs.setup.outputs.assets_hash }}
- name: Checkout wasp-assets
if: steps.wasp-assets-cache.outputs.cache-hit != 'true'
uses: actions/checkout@v5
with:
repository: WaspScripts/wasp-assets
path: ./Data/Assets
- name: Download WaspLib repo artifacts
uses: actions/download-artifact@v7
with:
name: wasplib
path: ./Includes/WaspLib
- name: Run tests
shell: bash
run: |
echo "Running test ${{ matrix.file }} on ${{ matrix.arch }}"
./Simba-${{ matrix.arch }}.exe --extractopenssl --run "./Includes/WaspLib/tests/${{ matrix.file }}"
release:
needs: tests
if: ${{ github.repository_owner == 'WaspScripts' && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Git
run: |
git config --global user.name "Wasp Bot"
git config --global user.email "waspbot@waspscripts.com"
- name: Recreate release branch
run: |
git fetch --all
git branch -D release || true
git checkout -b release origin/main
- name: Remove unwanted files
run: rm -rf tests
- name: Strip multi-line comments
run: find . -name "*.simba" -type f -exec perl -0777 -i -pe 's/\(\*.*?\*\)//gs' {} +
- name: Commit and push to release
run: |
git add .
git commit -m "Sync release with main and strip comments" || echo "No changes to commit"
git push origin release --force
- name: Check release branch size
run: |
echo "Release branch size:"
du -sh .
- name: Check main branch size
run: |
git fetch origin main
git checkout -b temp-main origin/main
echo "Main branch size:"
du -sh .
version:
needs: [setup, tests, release]
if: ${{ github.repository_owner == 'WaspScripts' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
ref: main
- name: Set up Git
run: |
git config --global user.name "Wasp Bot"
git config --global user.email "waspbot@waspscripts.com"
- name: Get current date
id: date
run: |
echo "CURRENT_YEAR=$(date +'%Y')" >> $GITHUB_ENV
echo "CURRENT_MONTH=$(date +'%m')" >> $GITHUB_ENV
echo "CURRENT_DAY=$(date +'%d')" >> $GITHUB_ENV
- name: Get commit hash
id: commit-hash
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Update version.simba on main branch
run: |
sed -i "s/WL_VERSION_YEAR: Integer = .*/WL_VERSION_YEAR: Integer = $CURRENT_YEAR;/" version.simba
sed -i "s/WL_VERSION_MONTH: Integer = .*/WL_VERSION_MONTH: Integer = $CURRENT_MONTH;/" version.simba
sed -i "s/WL_VERSION_DAY: Integer = .*/WL_VERSION_DAY: Integer = $CURRENT_DAY;/" version.simba
sed -i "s/WL_VERSION_COMMIT_HASH: String = .*/WL_VERSION_COMMIT_HASH: String = '$COMMIT_HASH';/" version.simba
- name: Push changes to main branch
run: |
git add version.simba
git commit -m "Automatic version bump to $CURRENT_YEAR.$CURRENT_MONTH.$CURRENT_DAY-$COMMIT_HASH" || echo "No changes to commit on main"
git push
- name: Switch to release branch
run: |
git fetch origin release
git checkout release
- name: Update version.simba on release branch
run: |
sed -i "s/WL_VERSION_YEAR: Integer = .*/WL_VERSION_YEAR: Integer = $CURRENT_YEAR;/" version.simba
sed -i "s/WL_VERSION_MONTH: Integer = .*/WL_VERSION_MONTH: Integer = $CURRENT_MONTH;/" version.simba
sed -i "s/WL_VERSION_DAY: Integer = .*/WL_VERSION_DAY: Integer = $CURRENT_DAY;/" version.simba
sed -i "s/WL_VERSION_COMMIT_HASH: String = .*/WL_VERSION_COMMIT_HASH: String = '$COMMIT_HASH';/" version.simba
- name: Push changes to release branch
run: |
git add version.simba
git commit -m "Automatic version bump to $CURRENT_YEAR.$CURRENT_MONTH.$CURRENT_DAY-$COMMIT_HASH" || echo "No changes to commit on release"
git push origin release
- name: Create git tag
id: tag
run: |
TAG_NAME="$CURRENT_YEAR.$CURRENT_MONTH.$CURRENT_DAY-$COMMIT_HASH"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
git tag $TAG_NAME
git push origin $TAG_NAME
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create $TAG_NAME --generate-notes
- name: Create Uploaded Release
run: |
ZIP_NAME="$TAG_NAME.zip"
git archive --format zip --output "$ZIP_NAME" HEAD
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV
- name: Upload release to Supabase
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
run: |
curl -X POST "$SUPABASE_URL/storage/v1/object/wasplib/$ZIP_NAME" \
-H "Authorization: Bearer $SUPABASE_KEY" \
-H "Content-Type: application/zip" \
--data-binary @"$ZIP_NAME"
curl -X DELETE "$SUPABASE_URL/storage/v1/object/wasplib/latest.zip" \
-H "Authorization: Bearer $SUPABASE_KEY"
curl -X POST "$SUPABASE_URL/storage/v1/object/copy" \
-H "Authorization: Bearer $SUPABASE_KEY" \
-H "Content-Type: application/json" \
-d "{
\"bucketId\": \"wasplib\",
\"sourceKey\": \"$ZIP_NAME\",
\"destinationKey\": \"latest.zip\"
}"
- name: Insert release metadata
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
SIMBA_BUILD_HASH: ${{ needs.setup.outputs.build_hash }}
run: |
DATA=$(jq -nc \
--arg version "$TAG_NAME" \
--arg simba "$SIMBA_BUILD_HASH" \
'{version: $version, simba: $simba}'
)
curl -X POST "$SUPABASE_URL/rest/v1/wasplib" \
-H "apikey: $SUPABASE_KEY" \
-H "Authorization: Bearer $SUPABASE_KEY" \
-H "Content-Type: application/json" \
-H "Content-Profile: scripts" \
-d "$DATA"
- name: Discord notification
shell: bash
run: |
BODY=$(jq -nc \
--arg title "WaspLib Version $TAG_NAME" \
--arg desc "${{ github.event.head_commit.message || 'No commit message available' }}
Download: https://github.com/WaspScripts/WaspLib/releases/tag/$TAG_NAME" \
--arg url "https://github.com/WaspScripts/WaspLib/commit/${{ github.sha }}" \
--arg foot "Author: ${{ github.event.head_commit.author.name }}" \
--argjson color 16742912 \
'{embeds:[{title:$title,description:$desc,url:$url,color:$color,footer:{text:$foot}}]}')
curl \
-H "Content-Type: application/json" \
-d "$BODY" \
${{ secrets.UPDATES_WEBHOOK }}