A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(release): the mirror stopped following releases, and had no stable link
yhhe9fd1d785e58
diff --git a/.github/workflows/mirror-release.yml b/.github/workflows/mirror-release.ymlindex 8c617fe66..c6eb7a39b 100644--- a/.github/workflows/mirror-release.yml+++ b/.github/workflows/mirror-release.yml@@ -9,6 +9,11 @@ name: Mirror a release# when a copy is missing, stale or wrong. That is what lets this run last, fail# without failing a release, and be pointed at a version published months ago.#+# Two things at the bucket root are addressed by name rather than by version, so+# that whoever reads them always gets the newest release without being told which+# one that is: `latest.json` (the editor's update check, and the website's labels)+# and `latest/` (the installers the website's download buttons link to).+## It runs when a release is PUBLISHED, not when a tag is pushed: this project's# pipeline uploads into a draft that a maintainer reviews, and a draft cannot be# downloaded by tag — the first run of this job found that out by failing with@@ -93,21 +98,87 @@ jobs:TAG: ${{ inputs.tag || github.event.release.tag_name }}IS_LATEST: ${{ steps.latest.outputs.is_latest }}run: |+ shopt -s nullglobversion="${TAG#v}"+ base="${PUBLIC_BASE%/}"aws s3 sync mirror "s3://$BUCKET/v$version/" --endpoint-url "$ENDPOINT" --no-progress+ if [ "$IS_LATEST" != "true" ]; then+ echo "not the newest release — leaving latest.json and latest/ alone"+ exit 0+ fi++ # Stable aliases. The website links to latest/<installer>, which must+ # keep working across releases without anyone editing a page — so each+ # installer is copied (server-side, no re-upload) to a name that carries+ # no version, and Content-Disposition puts the versioned name back on+ # the file the moment it lands in someone's Downloads folder.+ alias_to() {+ src="$1"; dst="$2"+ aws s3 cp "s3://$BUCKET/v$version/$(basename "$src")" "s3://$BUCKET/latest/$dst" \+ --endpoint-url "$ENDPOINT" --no-progress \+ --metadata-directive REPLACE \+ --content-type application/octet-stream \+ --content-disposition "attachment; filename=\"$(basename "$src")\"" \+ --cache-control "public, max-age=300"+ }++ win=(mirror/*Setup*.exe)+ mac=(mirror/*arm64.dmg)+ downloads='{}'+ if [ ${#win[@]} -gt 0 ]; then+ alias_to "${win[0]}" 'Estella-Editor-Setup.exe'+ downloads=$(jq -n --argjson d "$downloads" \+ --arg url "$base/latest/Estella-Editor-Setup.exe" \+ --arg name "$(basename "${win[0]}")" \+ --argjson size "$(stat -c%s "${win[0]}")" \+ '$d + {win: {url: $url, name: $name, size: $size}}')+ fi+ if [ ${#mac[@]} -gt 0 ]; then+ alias_to "${mac[0]}" 'Estella-Editor-arm64.dmg'+ downloads=$(jq -n --argjson d "$downloads" \+ --arg url "$base/latest/Estella-Editor-arm64.dmg" \+ --arg name "$(basename "${mac[0]}")" \+ --argjson size "$(stat -c%s "${mac[0]}")" \+ '$d + {"mac-arm64": {url: $url, name: $name, size: $size}}')+ fi+# Written last, and only for the newest release: an editor that reads# latest.json must never be pointed at a version whose assets are still- # uploading, nor at an older one somebody re-mirrored.- if [ "$IS_LATEST" = "true" ]; then- printf '{\n "version": "%s",\n "url": "%s/v%s/"\n}\n' \- "$version" "${PUBLIC_BASE%/}" "$version" > latest.json- cat latest.json- aws s3 cp latest.json "s3://$BUCKET/latest.json" \- --endpoint-url "$ENDPOINT" --cache-control "max-age=300"- else- echo "not the newest release — leaving latest.json alone"- fi+ # uploading, nor at an older one somebody re-mirrored. `version` and+ # `url` are the editor's update check; `downloads` is what the website+ # labels its buttons with, and adding to it cannot break the editor.+ jq -n --arg version "$version" --arg url "$base/v$version/" --argjson downloads "$downloads" \+ '{version: $version, url: $url, downloads: $downloads}' > latest.json+ cat latest.json+ aws s3 cp latest.json "s3://$BUCKET/latest.json" \+ --endpoint-url "$ENDPOINT" --cache-control "max-age=300"++ # The website reads latest.json from a different origin than the bucket, so+ # without this its version and size labels are blocked — the download links+ # themselves are plain navigations and never were. Re-applied every run+ # because it is one idempotent call, and never fatal: a mirror is a+ # shortcut, and a page that cannot label a button still links to it.+ - name: Allow the site to read latest.json+ if: steps.cfg.outputs.configured == 'true'+ continue-on-error: true+ env:+ AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}+ AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}+ AWS_DEFAULT_REGION: auto+ ENDPOINT: https://${{ secrets.R2_ACCOUNT_ID }}.r2.cloudflarestorage.com+ BUCKET: ${{ secrets.R2_BUCKET }}+ run: |+ aws s3api put-bucket-cors --bucket "$BUCKET" --endpoint-url "$ENDPOINT" \+ --cors-configuration '{+ "CORSRules": [{+ "AllowedOrigins": ["https://estellaengine.com", "https://www.estellaengine.com"],+ "AllowedMethods": ["GET", "HEAD"],+ "AllowedHeaders": ["*"],+ "ExposeHeaders": ["ETag", "Content-Length"],+ "MaxAgeSeconds": 86400+ }]+ }'- name: Reportif: steps.cfg.outputs.configured == 'true'@@ -119,7 +190,11 @@ jobs:echo "### Mirrored \`$TAG\`" >> "$GITHUB_STEP_SUMMARY"echo "" >> "$GITHUB_STEP_SUMMARY"echo "- assets: ${PUBLIC_BASE%/}/v$version/" >> "$GITHUB_STEP_SUMMARY"- echo "- latest.json written: ${{ steps.latest.outputs.is_latest }}" >> "$GITHUB_STEP_SUMMARY"+ echo "- latest.json + latest/ aliases written: ${{ steps.latest.outputs.is_latest }}" >> "$GITHUB_STEP_SUMMARY"+ if [ "${{ steps.latest.outputs.is_latest }}" = "true" ]; then+ echo "- windows: ${PUBLIC_BASE%/}/latest/Estella-Editor-Setup.exe" >> "$GITHUB_STEP_SUMMARY"+ echo "- macos: ${PUBLIC_BASE%/}/latest/Estella-Editor-arm64.dmg" >> "$GITHUB_STEP_SUMMARY"+ fi- name: Say why nothing happenedif: steps.cfg.outputs.configured != 'true'diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.ymlindex 54b8d5ebf..3b6bc9c88 100644--- a/.github/workflows/release-desktop.yml+++ b/.github/workflows/release-desktop.yml@@ -326,6 +326,19 @@ jobs:gh release edit "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --draft=false --latestecho "### Published $GITHUB_REF_NAME" >> "$GITHUB_STEP_SUMMARY"- # The mirror is NOT here: it follows `release: published`, because the assets it- # copies live in a draft until the publish job above flips it, and a draft cannot- # be downloaded by tag. See mirror-release.yml.+ # The mirror runs from here, after the publish above, because the assets it+ # copies live in a draft until then and a draft cannot be downloaded by tag.+ #+ # It used to follow the `release: published` event instead, which worked for+ # exactly as long as a human clicked Publish: an event raised by a job holding+ # GITHUB_TOKEN starts no workflow, so the moment publishing became automatic+ # the mirror stopped following releases and nothing said so. v0.34.1 published+ # with no mirrored copy at all. Calling the workflow is not an event, so this+ # cannot go quiet the same way; mirror-release.yml keeps its `release` trigger+ # for a release published by hand, and its dispatch for re-mirroring old tags.+ mirror:+ needs: publish+ uses: ./.github/workflows/mirror-release.yml+ secrets: inherit+ with:+ tag: ${{ github.ref_name }}