Skip to content

Commit

Permalink
Change rive-react-* references to be the shortened namespace-named co…
Browse files Browse the repository at this point in the history
…nvention
  • Loading branch information
zplata committed Apr 22, 2022
1 parent 9398e0d commit 4429be4
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 22 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,31 @@ on:
branches:
- main
jobs:
determine_version:
name: Determine the next build version
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
outputs:
version: ${{ steps.echo_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
run: npm ci
working-directory: ./
- id: determine_version
name: Get Version
run: npm run release -- --ci --release-version | tail -n 1 > RELEASE_VERSION
working-directory: ./
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
- id: echo_version
run: echo "::set-output name=version::$(cat ./RELEASE_VERSION)"

merge_job:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs: [determine_version]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
Expand All @@ -33,4 +55,4 @@ jobs:
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
run: npm run release
run: npm run release -- --ci
3 changes: 1 addition & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

set -e

# Run the build and copy to each react-variant build for npm release
npm run build
# Copy the build to each react-variant build for npm release
cp -r ./dist ./npm/react-webgl
cp -r ./dist ./npm/react-canvas

Expand Down
2 changes: 1 addition & 1 deletion scripts/bump_all_versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ for dir in ./npm/*; do
pushd $dir > /dev/null
repo_name=`echo $dir | sed 's:.*/::' | sed 's/_/-/g'`
echo Bumping version of $repo_name
../../scripts/bump_version.sh $repo_name
../../scripts/bump_version.sh $repo_name $RELEASE_VERSION
popd > /dev/null
done
4 changes: 2 additions & 2 deletions scripts/bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
NPM_VERSIONS=`npm show rive-react versions`
node $SCRIPT_DIR/nextVersion.js "$NPM_VERSIONS" `pwd`
# RELEASE_VERSION will come from an env variable passed in from the GH action workflow
node $SCRIPT_DIR/nextVersion.js "$RELEASE_VERSION" `pwd`
19 changes: 7 additions & 12 deletions scripts/nextVersion.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
const fs = require('fs');
const path = process.argv[3];
const package = require(path + '/package.json');
let versions = JSON.parse(process.argv[2].trim().replace(/\'/g, '"'));
const current = package.version;
// Don't work with alpha/beta/rc tags, maybe a better regex here?
versions = versions.filter((ver) => {
return !/[a-zA-Z]/.test(ver);
});
const currentVersion = package.version;
const nextVersion = process.argv[2].trim().replace(/\'/g, '"');

const latest = versions[versions.length - 1];
if (!nextVersion || nextVersion === currentVersion) {
throw new Error('Next version is not defined or is a version that already exists');
}

// Returns -1 if first is less than second, 1 if first is greater than second, otherwise 0 if equal.
function compareVersion(first, second) {
Expand All @@ -35,10 +33,7 @@ function compareVersion(first, second) {
return 0;
}

if (compareVersion(current, latest) <= 0) {
const parts = latest.split('.').map((value) => parseInt(value));
// TODO: Need to make this smarter, because the semver can change on rive-react
parts[parts.length - 1] = parts[parts.length - 1] + 1;
package.version = parts.join('.');
if (compareVersion(currentVersion, nextVersion) <= 0) {
package.version = nextVersion;
fs.writeFileSync(path + '/package.json', JSON.stringify(package, null, 2));
}
2 changes: 1 addition & 1 deletion scripts/publish_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -e
for dir in ./npm/*; do
pushd $dir > /dev/null
echo Publishing `echo $dir | sed 's:.*/::'`
npm publish $@
npm publish --access public
popd > /dev/null
done
6 changes: 3 additions & 3 deletions scripts/setup_all_packages.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
set -e

echo Copying package.json to rive-react npm package folders
echo "Copying package.json to rive-react npm package folders"

cp package.json npm/rive-react-canvas
cp package.json npm/rive-react-webgl
cp package.json npm/react-canvas
cp package.json npm/react-webgl

# Bump the version number of every npm module in the npm folder.
for dir in ./npm/*; do
Expand Down

0 comments on commit 4429be4

Please sign in to comment.