From 11323309cbebbcfe908dd6ab1b37155dcadbb587 Mon Sep 17 00:00:00 2001
From: Alec Reynolds <alec+git@lando.dev>
Date: Fri, 25 Oct 2024 12:23:31 -0700
Subject: [PATCH] Generate an edge release when stable releases are created.
 (#42)

---
 .github/workflows/release.yml | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1ce7aca..1135c23 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -11,13 +11,12 @@ jobs:
     runs-on: ${{ matrix.os }}
     env:
       TERM: xterm
-      PRERELEASE_TAG: edge
     strategy:
       matrix:
         os:
           - ubuntu-24.04
         node-version:
-          - '18'
+          - '20'
     steps:
       # Install deps and cache
       - name: Checkout code
@@ -49,14 +48,23 @@ jobs:
       # Deploy
       - name: Publish to npm
         run: |
+          VERSION=$(node -p "require('./package.json').version")
+          PACKAGE=$(node -p "require('./package.json').name")
+
           if [ "${{ github.event.release.prerelease }}" ==  "false" ]; then
             npm publish --access public --dry-run
             npm publish --access public
-            echo "::notice title=Published ${{ github.ref_name }} to @${{ github.repository }}::This is a stable release published to the default 'latest' npm tag"
+            npm dist-tag add "$PACKAGE@$VERSION" edge
+
+            echo "::notice title=Published $VERSION to $PACKAGE::This is a stable release published to the default 'latest' npm tag"
+            echo "::notice title=Updated latest tag to $VERSION::The stable tag now points to $VERSION"
+            echo "::notice title=Updated edge tag to $VERSION::The edge tag now points to $VERSION"
           else
-            npm publish --access public --tag ${{ env.PRERELEASE_TAG }} --dry-run
-            npm publish --access public --tag ${{ env.PRERELEASE_TAG }}
-            echo "::notice title=Published ${{ github.ref_name }} to @${{ github.repository }}@${{ env.PRERELEASE_TAG }}::This is a pre-release published to the '${{ env.PRERELEASE_TAG }}' npm tag"
+            npm publish --access public --tag edge --dry-run
+            npm publish --access public --tag edge
+
+            echo "::notice title=Published $VERSION to $PACKAGE::This is a prerelease published to the 'edge' npm tag"
+            echo "::notice title=Updated edge tag to $VERSION::The edge tag now points to $VERSION"
           fi
         env:
           NODE_AUTH_TOKEN: ${{secrets.NPM_DEPLOY_TOKEN}}