Skip to content

Commit 1e7e956

Browse files
Merge branch 'feat/args-profile'
2 parents a6e0684 + 21736d4 commit 1e7e956

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

.github/workflows/publish-on-tag.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
steps:
2626
- name: Checkout repository
2727
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
2830

2931
- name: Set up Node.js
3032
uses: actions/setup-node@v4
@@ -42,21 +44,28 @@ jobs:
4244
env:
4345
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4446
run: |
45-
# Ensure we are on the right tag ref when triggered by push
47+
set -e
4648
if [ "${{ github.event_name }}" = "push" ]; then
4749
TAG_REF="${GITHUB_REF#refs/tags/}"
48-
echo "Publishing version for tag $TAG_REF"
50+
echo "Publishing version for pushed tag $TAG_REF"
4951
else
5052
TAG_REF="${{ github.event.inputs.tag || '' }}"
51-
echo "Manual publish for tag $TAG_REF (if empty, uses current ref)"
53+
if [ -z "$TAG_REF" ]; then
54+
git fetch --tags --force
55+
TAG_REF=$(git tag -l 'v*' | sort -V | tail -1)
56+
echo "No tag input given; falling back to latest tag $TAG_REF"
57+
else
58+
echo "Manual publish for input tag $TAG_REF"
59+
fi
5260
fi
5361
54-
if [ -n "$TAG_REF" ]; then
55-
VERSION_FROM_TAG="${TAG_REF#v}"
56-
echo "Setting package.json version to $VERSION_FROM_TAG based on tag $TAG_REF"
57-
npm version "$VERSION_FROM_TAG" --no-git-tag-version
58-
else
59-
echo "TAG_REF is empty, skipping package.json version update"
62+
if [ -z "$TAG_REF" ]; then
63+
echo "No tag available to publish; aborting" >&2
64+
exit 1
6065
fi
6166
67+
VERSION_FROM_TAG="${TAG_REF#v}"
68+
echo "Setting package.json version to $VERSION_FROM_TAG (from $TAG_REF)"
69+
npm version "$VERSION_FROM_TAG" --no-git-tag-version
70+
6271
npm publish --provenance --access public

0 commit comments

Comments
 (0)