Skip to content

Commit a0fc2f7

Browse files
committed
Fix workflow
1 parent cacfb20 commit a0fc2f7

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Build and Publish Package
22

33
on:
44
push:
5+
branches: [ main ]
56
tags: [ 'v*' ]
67
workflow_dispatch:
78

@@ -28,12 +29,22 @@ jobs:
2829
- name: Build
2930
run: npm run build
3031

31-
- name: Set version from tag
32-
if: startsWith(github.ref, 'refs/tags/')
32+
- name: Set version
33+
id: set_version
3334
run: |
34-
TAG=${GITHUB_REF#refs/tags/}
35-
VERSION=${TAG#v}
35+
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
36+
# If this is a tag push, use the tag version
37+
TAG=${GITHUB_REF#refs/tags/}
38+
VERSION=${TAG#v}
39+
else
40+
# If this is not a tag push, use the current version and add timestamp
41+
CURRENT_VERSION=$(node -p "require('./package.json').version")
42+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
43+
VERSION="${CURRENT_VERSION}-${TIMESTAMP}"
44+
fi
45+
echo "Using version: $VERSION"
3646
npm version $VERSION --no-git-tag-version
47+
echo "version=$VERSION" >> $GITHUB_OUTPUT
3748
3849
- name: Publish to GitHub Packages
3950
run: npm publish

0 commit comments

Comments
 (0)