Skip to content

Commit

Permalink
Fix github release process (#238)
Browse files Browse the repository at this point in the history
* Fix github release process, distinguishing between release and pre release

* Name each github workflow differently

* Update scripts, package.json

* Remove v check

* Remove force

* Bump to 3.8.3
  • Loading branch information
lmeier committed Aug 2, 2023
1 parent b1f879c commit be23434
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 6 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/radar-pre-release-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Publish beta package to npmjs
on:
release:
types: [ prereleased ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run check-beta-tag
- run: npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 3 additions & 2 deletions .github/workflows/radar-release-actions.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish Package to npmjs
name: Publish latest package to npmjs
on:
release:
types: [ published ]
types: [ released ]
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -13,6 +13,7 @@ jobs:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run check-latest-tag
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "React Native module for Radar, the leading geofencing and location tracking platform",
"homepage": "https://radar.com",
"license": "Apache-2.0",
"version": "3.8.2",
"version": "3.8.3",
"main": "js/index.js",
"files": [
"android",
Expand All @@ -13,7 +13,9 @@
"react-native-radar.podspec"
],
"scripts": {
"test": "jest ./test/*.test.js"
"test": "jest ./test/*.test.js",
"check-latest-tag": "node ./scripts/check-latest-tag.cjs",
"check-beta-tag": "node ./scripts/check-beta-tag.cjs"
},
"jest": {
"preset": "react-native",
Expand Down
22 changes: 22 additions & 0 deletions scripts/check-beta-tag.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fs = require('fs');
const packageJSON = require('../package.json');
const packageLockJSON = require('../package-lock.json');

let tagVersion = process.env.GITHUB_REF_NAME || '';
console.log('Checking tag:', tagVersion);


if (!tagVersion.includes('-beta')) {
console.error('Prelease version should contain a "-beta" suffix');
process.exit(1);
}

if (tagVersion !== packageJSON.version) {
console.error('VERSION MISMATCH - version does not match package.json.');
process.exit(1);
}
if (tagVersion !== packageLockJSON.version) {
console.error('VERSION MISMATCH - version does not match package-lock.json.');
process.exit(1);
}
console.log('Tag OK.', tagVersion);
22 changes: 22 additions & 0 deletions scripts/check-latest-tag.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fs = require('fs');
const packageJSON = require('../package.json');
const packageLockJSON = require('../package-lock.json');

let tagVersion = process.env.GITHUB_REF_NAME || '';
console.log('Checking tag:', tagVersion);


if (tagVersion.includes('-')) {
console.error('Latest tag should not include any suffix:', `-${tagVersion.split('-')[1]}`);
process.exit(1);
}

if (tagVersion !== packageJSON.version) {
console.error('VERSION MISMATCH - version does not match package.json.');
process.exit(1);
}
if (tagVersion !== packageLockJSON.version) {
console.error('VERSION MISMATCH - version does not match package-lock.json.');
process.exit(1);
}
console.log('Tag OK.', tagVersion);

0 comments on commit be23434

Please sign in to comment.