Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .changeset/bump-to-v5.md

This file was deleted.

37 changes: 10 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- stable

concurrency: ${{ github.workflow }}-${{ github.ref }}

Expand Down Expand Up @@ -67,28 +66,21 @@ jobs:
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

- name: Manage npm dist-tags for published packages
- name: Add latest dist-tag to published packages
if: steps.changesets.outputs.published == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
run: |
FAILED=0
BRANCH="${GITHUB_REF_NAME}"

# Parse published packages and add latest tag to each
while IFS= read -r pkg; do
NAME=$(echo "$pkg" | jq -r '.name')
VERSION=$(echo "$pkg" | jq -r '.version')

if [ "$BRANCH" = "stable" ]; then
# GA releases from stable get the 'latest' dist-tag
echo "Adding 'latest' dist-tag to ${NAME}@${VERSION}..."
if ! npm dist-tag add "${NAME}@${VERSION}" latest; then
echo "::error::Failed to add 'latest' dist-tag to ${NAME}@${VERSION}"
FAILED=1
fi
else
# Pre-release versions from main already get the 'beta' tag from changeset publish
echo "Skipping 'latest' dist-tag for pre-release ${NAME}@${VERSION} (published with 'beta' tag by changesets)"
echo "Adding 'latest' dist-tag to ${NAME}@${VERSION}..."
if ! npm dist-tag add "${NAME}@${VERSION}" latest; then
echo "::error::Failed to add 'latest' dist-tag to ${NAME}@${VERSION}"
FAILED=1
fi
done < <(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -c '.[]')

Expand All @@ -108,31 +100,22 @@ jobs:
TITLE=$(echo "$RELEASE_JSON" | jq -r '.title')
BODY=$(echo "$RELEASE_JSON" | jq -r '.body')

# Determine release flags based on branch
if [ "$GITHUB_REF_NAME" = "stable" ]; then
PRERELEASE="false"
LATEST_FLAG="--latest"
else
PRERELEASE="true"
LATEST_FLAG="--latest=false"
fi

# Check if a release with this tag already exists
if gh release view "$TAG" &>/dev/null; then
echo "Release $TAG already exists, updating..."
gh release edit "$TAG" \
--title "$TITLE" \
--notes "$BODY" \
$LATEST_FLAG \
--prerelease=$PRERELEASE
--latest \
--prerelease=false
else
echo "Creating new release $TAG..."
gh release create "$TAG" \
--target "${{ github.sha }}" \
--title "$TITLE" \
--notes "$BODY" \
$LATEST_FLAG \
--prerelease=$PRERELEASE
--latest \
--prerelease=false
fi

- name: Post release notes to Slack
Expand Down
Loading