From 5bf66b8e50a63b8a7045b9d2efdf7a7733d09add Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 29 Apr 2025 04:22:59 +0300 Subject: [PATCH] ci: add fixed short link for released version eg v90.mcraft.fun --- .github/workflows/preview.yml | 2 +- .github/workflows/{publish.yml => release.yml} | 11 ++++++++++- scripts/githubActions.mjs | 10 ++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) rename .github/workflows/{publish.yml => release.yml} (83%) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index b4908d8d..f35e6a00 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -1,4 +1,4 @@ -name: Vercel Deploy Preview +name: Vercel PR Deploy (Preview) env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} diff --git a/.github/workflows/publish.yml b/.github/workflows/release.yml similarity index 83% rename from .github/workflows/publish.yml rename to .github/workflows/release.yml index 1294f9ff..28c1e34c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/release.yml @@ -29,6 +29,9 @@ jobs: run: pnpx zardoy-release empty --skip-github --output-file assets/release.json env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get releasing alias + run: node scripts/githubActions.mjs getReleasingAlias + id: alias - name: Download Generated Sounds map run: node scripts/downloadSoundsMap.mjs - run: vercel build --token=${{ secrets.VERCEL_TOKEN }} --prod @@ -45,6 +48,12 @@ jobs: with: run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --prod id: deploy + - name: Set deployment alias + if: ${{ steps.alias.outputs.alias != '' && steps.alias.outputs.alias != 'mcraft.fun' && steps.alias.outputs.alias != 's.mcraft.fun' }} + run: | + for alias in $(echo ${{ steps.alias.outputs.alias }} | tr "," "\n"); do + vercel alias set ${{ steps.deploy.outputs.stdout }} $alias --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro + done # publish to github - run: cp vercel.json .vercel/output/static/vercel.json - uses: peaceiris/actions-gh-pages@v3 @@ -70,7 +79,7 @@ jobs: zip -r ../self-host.zip . - run: | - pnpx zardoy-release node --footer "This release URL: ${{ steps.deploy.outputs.stdout }}" + pnpx zardoy-release node --footer "This release URL: $(echo ${{ steps.alias.outputs.alias }} | cut -d',' -f1) (Vercel URL: ${{ steps.deploy.outputs.stdout }})" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # has possible output: tag diff --git a/scripts/githubActions.mjs b/scripts/githubActions.mjs index ab786ea9..3864d6c2 100644 --- a/scripts/githubActions.mjs +++ b/scripts/githubActions.mjs @@ -15,6 +15,16 @@ const fns = { // set github output setOutput('alias', alias[1]) } + }, + getReleasingAlias() { + const final = (ver) => `${ver}.mcraft.fun,${ver}.pcm.gg` + const releaseJson = JSON.parse(fs.readFileSync('./assets/release.json', 'utf8')) + const tag = releaseJson.latestTag + const [major, minor, patch] = tag.replace('v', '').split('.') + if (major === '0' && minor === '1') { + return final(`v${patch}`) + } + return final(tag) } }