add release it for automated github releases and npm publish

This commit is contained in:
Arthur Vivian
2021-06-28 12:59:26 +01:00
parent ae1db331d9
commit 91523a3786
6 changed files with 1611 additions and 37 deletions

View File

@@ -23,7 +23,13 @@ jobs:
run: npm test
- name: Build
run: npm build
- name: Publish
- name: Git config
run: |
git config --local user.email 'hello@rive.app'
git config --local user.name ${{ github.actor }}
- name: Authenticate with registry
run: npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
- name: Release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm run publish
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
run: npm run release

12
.release-it.json Normal file
View File

@@ -0,0 +1,12 @@
{
"git": {
"commitMessage": "chore: release ${version}",
"tagName": "v${version}"
},
"npm": {
"publish": true
},
"github": {
"release": true
}
}

1590
package-lock.json generated
View File

File diff suppressed because it is too large Load Diff

View File

@@ -10,7 +10,7 @@
"lint": "eslint -c .eslintrc.js 'src/**/*{.ts,.tsx}'",
"format": "prettier --write src",
"types:check": "tsc --noEmit",
"publish": "./scripts/publish.sh"
"release": "release-it"
},
"repository": {
"type": "git",

View File

@@ -1,27 +0,0 @@
const fs = require('fs');
const package = require('../package.json');
function parseVersion(v) {
return v.split('.').map((n) => Number.parseInt(n, 10));
}
const packageVersion = parseVersion(package.version);
// Last version seems to always be latest.
const publishedVersion = parseVersion(JSON.parse(process.argv[2]).pop());
const isGreater = (first, second) => {
// Assumes first and second have same number of version number
const zipped = first.map((n, i) => [n, second[i]]);
return zipped.some(([a, b]) => a > b);
};
// If package version is greater than what's published, we use that.
if (isGreater(packageVersion, publishedVersion)) {
return;
}
// Otherwise increment the publishedVersions patch number and push to the package.json
const newVersion = publishedVersion;
newVersion[2]++;
package.version = newVersion.join('.');
fs.writeFileSync('./package.json', JSON.stringify(package, null, 2));

View File

@@ -1,5 +0,0 @@
#!/bin/bash
set -e
NPM_VERSIONS=`npm show rive-react versions --json`
node ./scripts/next_version.js "$NPM_VERSIONS"
npm publish