Skip to content

Commit 76c4fc9

Browse files
committed
Update build.yml
1 parent 30507ba commit 76c4fc9

File tree

1 file changed

+58
-34
lines changed

1 file changed

+58
-34
lines changed

.github/workflows/build.yml

Lines changed: 58 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -109,65 +109,89 @@ jobs:
109109
with:
110110
path: artifacts
111111

112-
# Copy only archives (skip .sha256 for nightly)
113-
- name: Gather files (zip + tar.gz, no checksums)
112+
- name: Gather files (zip only)
114113
shell: bash
115114
run: |
116115
set -euo pipefail
117116
mkdir -p upload
118-
find artifacts -type f \( -name '*.zip' -o -name '*.tar.gz' \) -print0 | xargs -0 -I{} cp "{}" upload/
117+
find artifacts -type f -name '*.zip' -print0 | xargs -0 -I{} cp "{}" upload/
119118
120-
# Ensure both Windows (.zip) and Linux (.tar.gz) exist
121-
- name: Verify we have both archive types
119+
- name: Verify we have both platform zips
122120
shell: bash
123121
run: |
124122
shopt -s nullglob
125123
zips=(upload/*.zip)
126-
echo "Found ${#zips[@]} zip(s) and ${#tars[@]} tar.gz file(s)."
127-
if (( ${#zips[@]} != 2 )); then
128-
echo "ERROR: Expected both .zip (Windows) and .zip (Linux) artifacts."
129-
ls -alR upload || true
124+
echo "Found ${#zips[@]} zip(s):"; ls -alh upload
125+
if (( ${#zips[@]} < 2 )); then
126+
echo "ERROR: expected at least Win + Linux zips."
130127
exit 1
131128
fi
132-
133-
# Rename artifacts: replace ONLY the version token between hyphens with 'nightly', keep platform + extension
134-
- name: Normalize nightly filenames (preserve platform + extension)
129+
- name: Normalize nightly filenames
135130
shell: bash
136131
run: |
137132
set -euo pipefail
138-
shopt -s nullglob
139-
for f in upload/*; do
133+
for f in upload/*.zip; do
140134
base="$(basename "$f")"
141-
ext=""; stem="$base"
142-
if [[ "$base" == *.* ]]; then
143-
ext=".${base##*.}" # extension incl. dot
144-
stem="${base%.*}" # name without extension
145-
fi
146-
# Replace the first hyphen-delimited numeric version token with 'nightly'
147-
# Example: wurst-compiler-1.8.1.0-linux-x64 -> wurst-compiler-nightly-linux-x64
135+
stem="${base%.zip}"
148136
new_stem="$(echo "$stem" | sed -E 's/-[0-9]+(\.[0-9]+)*-/-nightly-/' )"
149-
new="${new_stem}${ext}"
150-
if [[ "$base" != "$new" ]]; then
151-
mv -f "upload/$base" "upload/$new"
152-
fi
137+
new="upload/${new_stem}.zip"
138+
if [[ "upload/$base" != "$new" ]]; then mv -f "upload/$base" "$new"; fi
153139
done
154-
echo "After rename:"
155-
ls -alh upload
140+
echo "Renamed to:"; ls -alh upload
156141
157-
- name: Publish Nightly Release (rolling 'nightly' tag)
142+
# Delete old release + tag, then create a fresh one at HEAD
143+
- name: Recreate nightly release and tag at HEAD
144+
uses: actions/github-script@v7
145+
with:
146+
script: |
147+
const { owner, repo } = context.repo;
148+
const tag = 'nightly';
149+
150+
// Delete existing release (if any)
151+
try {
152+
const rel = await github.rest.repos.getReleaseByTag({ owner, repo, tag });
153+
await github.rest.repos.deleteRelease({ owner, repo, release_id: rel.data.id });
154+
core.info(`Deleted release id=${rel.data.id}`);
155+
} catch (e) {
156+
core.info(`No previous release to delete: ${e.message}`);
157+
}
158+
159+
// Delete tag (if any)
160+
try {
161+
await github.rest.git.deleteRef({ owner, repo, ref: `tags/${tag}` });
162+
core.info('Deleted ref tags/nightly');
163+
} catch (e) {
164+
core.info(`No existing tag to delete: ${e.message}`);
165+
}
166+
167+
// Create fresh prerelease at the current commit
168+
const { data: rel2 } = await github.rest.repos.createRelease({
169+
owner, repo,
170+
tag_name: tag,
171+
target_commitish: context.sha,
172+
name: 'Nightly Build (master)',
173+
body: 'Nightly build for the latest commit on `master`.\nThis release is automatically updated on each push.',
174+
draft: false,
175+
prerelease: true,
176+
make_latest: 'false' // MUST be a string
177+
});
178+
core.setOutput('upload_url', rel2.upload_url);
179+
180+
- name: Publish Nightly Release (upload assets)
158181
uses: softprops/action-gh-release@v2
159182
with:
160183
tag_name: nightly
161-
name: Nightly Build (master)
184+
target_commitish: ${{ github.sha }}
162185
prerelease: true
163186
draft: false
164-
make_latest: false
165-
generate_release_notes: false
187+
make_latest: "false" # keep as string here too
188+
name: Nightly Build (master)
166189
body: |
167190
Nightly build for the latest commit on `master`.
168-
This release is automatically updated in-place (same tag).
169-
files: |
170-
upload/**
191+
This release is automatically updated on each push.
192+
files: upload/**
171193
fail_on_unmatched_files: false
172194
env:
173195
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196+
197+

0 commit comments

Comments
 (0)