File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ name: Build and Publish Package
22
33on :
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
You can’t perform that action at this time.
0 commit comments