Skip to content

Commit

Permalink
fix: add release script
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarconr committed Apr 21, 2022
1 parent 4f0a719 commit 277012b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/release.yaml
@@ -0,0 +1,30 @@
name: 'Publish to npm'
on:
push:
tags:
- 'v*'

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v3
- name: Publish to npm
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
- run: |
yarn install --frozen-lockfile
- run: |
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');
}
3 changes: 2 additions & 1 deletion tsconfig.json
Expand Up @@ -76,6 +76,7 @@
"snapshots",
"coverage",
"website",
"setupJest.js"
"setupJest.js",
"scripts"
]
}

0 comments on commit 277012b

Please sign in to comment.