Skip to content

Commit

Permalink
Improved publihsing
Browse files Browse the repository at this point in the history
- when git tag contains version with alpha substring, then the package is built as pre-release one and its version is read from the tag itself
- when git tag contains version with no alpha, then the version is read from package.json and it is published as latest
  • Loading branch information
mikalai-snap committed Aug 13, 2024
1 parent 0eccd5b commit de86557
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Publish to npm
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'

jobs:
build:
Expand All @@ -18,6 +19,19 @@ jobs:
with:
node-version: 20.x
cache: 'npm'
registry-url: 'https://registry.npmjs.org/'

- name: Determine pre-release tag
id: release-tag
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "Detected tag: $TAG_NAME"
if [[ "$TAG_NAME" == *-alpha.* ]]; then
echo "tag=alpha" >> $GITHUB_ENV
npm version --no-git-tag-version $TAG_NAME
else
echo "tag=latest" >> $GITHUB_ENV
fi
- name: Install dependencies
run: npm ci
Expand All @@ -29,6 +43,6 @@ jobs:
run: npm run compile

- name: Publish
run: npm publish --access public
run: npm publish --access public --tag ${{ env.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit de86557

Please sign in to comment.