1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-14 00:19:16 +01:00

fix: add release script

This commit is contained in:
Ivar Conradi Østhus 2022-04-21 00:02:46 +02:00
parent 2f37951ea2
commit 4f3ea3c1fd
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09
3 changed files with 50 additions and 1 deletions

30
.github/workflows/release.yaml vendored Normal file
View File

@ -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
scripts/npm-tag.js Normal file
View File

@ -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');
}

View File

@ -76,6 +76,7 @@
"snapshots",
"coverage",
"websitev2",
"setupJest.js"
"setupJest.js",
"scripts"
]
}