fix: stable release時にnext dist-tagを自動同期
This commit is contained in:
parent
8384027f21
commit
b9f8addaea
37
.github/workflows/auto-tag.yml
vendored
37
.github/workflows/auto-tag.yml
vendored
@ -52,12 +52,47 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
VERSION="${{ needs.tag.outputs.tag }}"
|
VERSION="${{ needs.tag.outputs.tag }}"
|
||||||
VERSION="${VERSION#v}"
|
VERSION="${VERSION#v}"
|
||||||
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
if echo "$VERSION" | grep -qE '(alpha|beta|rc|next)'; then
|
if echo "$VERSION" | grep -qE '(alpha|beta|rc|next)'; then
|
||||||
echo "tag=next" >> "$GITHUB_OUTPUT"
|
echo "tag=next" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
echo "tag=latest" >> "$GITHUB_OUTPUT"
|
echo "tag=latest" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- run: npm publish --tag ${{ steps.npm-tag.outputs.tag }}
|
- name: Publish package
|
||||||
|
run: npm publish --tag ${{ steps.npm-tag.outputs.tag }}
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: Sync next tag on stable release
|
||||||
|
if: steps.npm-tag.outputs.tag == 'latest'
|
||||||
|
run: |
|
||||||
|
PACKAGE_NAME=$(node -p "require('./package.json').name")
|
||||||
|
VERSION="${{ steps.npm-tag.outputs.version }}"
|
||||||
|
|
||||||
|
for attempt in 1 2 3; do
|
||||||
|
if npm dist-tag add "${PACKAGE_NAME}@${VERSION}" next; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if [ "$attempt" -eq 3 ]; then
|
||||||
|
echo "Failed to sync next tag after 3 attempts."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep $((attempt * 5))
|
||||||
|
done
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
|
- name: Verify dist-tags
|
||||||
|
run: |
|
||||||
|
PACKAGE_NAME=$(node -p "require('./package.json').name")
|
||||||
|
LATEST=$(npm view "${PACKAGE_NAME}" dist-tags.latest)
|
||||||
|
NEXT=$(npm view "${PACKAGE_NAME}" dist-tags.next || true)
|
||||||
|
|
||||||
|
echo "latest=${LATEST}"
|
||||||
|
echo "next=${NEXT}"
|
||||||
|
|
||||||
|
if [ "${{ steps.npm-tag.outputs.tag }}" = "latest" ] && [ "${LATEST}" != "${NEXT}" ]; then
|
||||||
|
echo "Expected next to match latest on stable release, but they differ."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user