Skip to content

Commit

Permalink
add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-unleash committed Jul 19, 2022
1 parent 52ff880 commit cd7a34b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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'
cache: 'yarn'
- run: |
yarn install --frozen-lockfile
- run: |
LATEST=$(npm show @unleash/proxy-client-js version)
TAG=$(node scripts/npm-tag.js $LATEST)
npm publish --tag ${TAG:-latest}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/release_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Releases'
on:
push:
tags:
- 'v*'

jobs:
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build changelog
id: github_release
uses: metcalfc/changelog-generator@v0.4.4
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ steps.github_release.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
18 changes: 18 additions & 0 deletions scripts/npm-tag.js
Original file line number Diff line number Diff line change
@@ -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 cd7a34b

Please sign in to comment.