Skip to content

Commit

Permalink
fix: update npm publish script to select correct dist-tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarconr committed Apr 20, 2022
1 parent 60c1265 commit 636f032
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/release.yaml
Expand Up @@ -23,7 +23,8 @@ jobs:
- run: |
yarn install --frozen-lockfile
- run: |
TAG=$(echo $GITHUB_REF_NAME | grep -oP '^v\d+\.\d+\.\d+-?\K(\w+)?')
LATEST=$(npm show unleash-server version)
TAG=${node scripts/npm-tag.js $LATEST}
npm publish --tag ${TAG:-latest}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
18 changes: 18 additions & 0 deletions scripts/npm-tag.js
@@ -0,0 +1,18 @@
const semver = require('semver');

const latestUnleashVersion = process.argv[2];

const version = require('../package.json').version;

function isPrerelease(version) {
const arr = semver.prerelease(version);
return arr && arr.length > 0;
}

if(isPrerelease(version)){
console.log('beta')
}else if(semver.gt(version, latestUnleashVersion)) {
console.log('latest');
} else {
console.log('previous');
}

0 comments on commit 636f032

Please sign in to comment.