mirror of
https://github.com/rive-app/rive-react.git
synced 2026-03-13 08:22:30 +08:00
Publish on merge to master
This commit is contained in:
27
.github/workflows/publish.yml
vendored
Normal file
27
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
name: Publish to NPM
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
merge_job:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '12.x'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
- name: Install Modules
|
||||
run: npm ci
|
||||
- name: Run type check
|
||||
run: npm run types:check
|
||||
- name: Run Linter
|
||||
run: npm run lint
|
||||
- name: Run Tests
|
||||
run: npm test
|
||||
- name: Build
|
||||
run: npm build
|
||||
- name: Publish
|
||||
run: npm run publish
|
||||
3
.github/workflows/tests.yml
vendored
3
.github/workflows/tests.yml
vendored
@@ -1,6 +1,5 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||

|
||||

|
||||

|
||||
|
||||
# Rive React
|
||||
|
||||
React Runtime for [Rive](https://rive.app).
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
"build": "bunchee src/index.ts -m --no-sourcemap",
|
||||
"lint": "eslint -c .eslintrc.js 'src/**/*{.ts,.tsx}'",
|
||||
"format": "prettier --write src",
|
||||
"types:check": "tsc --noEmit"
|
||||
"types:check": "tsc --noEmit",
|
||||
"publish": "./scripts/publish.sh"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
27
scripts/next_version.js
Normal file
27
scripts/next_version.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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));
|
||||
5
scripts/publish.sh
Executable file
5
scripts/publish.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
NPM_VERSIONS=`npm show rive-react versions --json`
|
||||
node ./scripts/next_version.js "$NPM_VERSIONS"
|
||||
npm publish
|
||||
Reference in New Issue
Block a user