Skip to content

Commit

Permalink
chore: move to manual npm publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zplata committed Jul 25, 2023
1 parent 4496eff commit 4cce306
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 113 deletions.
81 changes: 30 additions & 51 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,28 @@
name: Publish to NPM
on:
pull_request:
types: [closed]
branches:
- main
workflow_dispatch:
inputs:
major:
description: 'Major'
type: boolean
default: false
minor:
description: 'Minor'
type: boolean
default: false
jobs:
determine_version:
name: Determine the next build version
if: github.event.pull_request.merged == true
publish_job:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.echo_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
run: npm install
working-directory: ./
- name: Git config
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Git config
run: |
git config --local user.email '[email protected]'
git config --local user.name ${{ github.actor }}
- name: Authenticate with registry
run: npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
- 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
with:
node-version: '16.x'
Expand All @@ -50,30 +35,24 @@ jobs:
run: npm run lint
- name: Run Tests
run: npm test
- name: Build main dist
run: npm run build
- name: Copy separated builds
run: ./scripts/build.sh
- name: Copy package jsons to separate react outputs
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: ./scripts/setup_all_packages.sh
- name: Bump Versions of react outputs
- if: ${{ inputs.major == true }}
name: Major Release - Bump version number, update changelog, push and tag
run: npm run release:major
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
PAT_GITHUB: ${{ secrets.PAT_GITHUB }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
RELEASE_VERSION: ${{ needs.determine_version.outputs.version }}
run: ./scripts/bump_all_versions.sh
- name: Git config
run: |
git config --local user.email '[email protected]'
git config --local user.name ${{ github.actor }}
- name: Authenticate with registry
run: npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }}
- name: Release rive-react
- if: ${{inputs.major == false && inputs.minor == true}}
name: Minor release - Bump version number, update changelog, push and tag
run: npm run release:minor
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
run: npm run release -- --ci
- name: Release @rive-app/react-* variants
PAT_GITHUB: ${{ secrets.PAT_GITHUB }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- if: ${{inputs.major == false && inputs.minor == false}}
name: Patch release - Bump version number, update changelog, push and tag
run: npm run release:patch
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
run: ./scripts/publish_all.sh
PAT_GITHUB: ${{ secrets.PAT_GITHUB }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
10 changes: 9 additions & 1 deletion .release-it.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"git": {
"addUntrackedFiles": true,
"requireCleanWorkingDir": false,
"commitMessage": "chore: release ${version}",
"tagName": "v${version}",
"changelog": "npx auto-changelog --stdout --commit-limit false --unreleased --template https://raw.githubusercontent.com/release-it/release-it/master/templates/changelog-compact.hbs"
Expand All @@ -12,6 +14,12 @@
"releaseName": "${version}"
},
"hooks": {
"after:bump": ["npx auto-changelog -p", "git add ./CHANGELOG.md"]
"after:version:bump": [
"npm run build",
"npm run setup-builds",
"npm run setup-packages",
"npx auto-changelog -p",
"npm run publish:all"
]
}
}
26 changes: 26 additions & 0 deletions npm/react-canvas/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@rive-app/react-canvas",
"version": "3.0.53",
"description": "React wrapper around the @rive-app/canvas library",
"main": "dist/index.js",
"typings": "dist/types/index.d.ts",
"files": [
"dist/**"
],
"repository": {
"type": "git",
"url": "git+https://github.com/rive-app/rive-react.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/rive-app/rive-react/issues"
},
"homepage": "https://github.com/rive-app/rive-react#readme",
"dependencies": {
"@rive-app/canvas": "1.2.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
}
}
26 changes: 26 additions & 0 deletions npm/react-webgl/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@rive-app/react-webgl",
"version": "3.0.53",
"description": "React wrapper around the @rive-app/webgl library",
"main": "dist/index.js",
"typings": "dist/types/index.d.ts",
"files": [
"dist/**"
],
"repository": {
"type": "git",
"url": "git+https://github.com/rive-app/rive-react.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/rive-app/rive-react/issues"
},
"homepage": "https://github.com/rive-app/rive-react#readme",
"dependencies": {
"@rive-app/webgl": "1.2.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
}
}
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@
"types:check": "tsc --noEmit",
"release": "release-it",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook -o docs-build"
"build-storybook": "build-storybook -o docs-build",
"release:patch": "npm run release -- --ci --dry-run",
"release:minor": "npm run release -- minor --ci --dry-run",
"release:major": "npm run release -- major --ci --dry-run",
"setup-builds": "./scripts/build.sh",
"setup-packages": "./scripts/setup_all_packages.sh",
"bump-versions": "./scripts/bump_all_versions.sh $npm_package_version",
"publish:all": "./scripts/publish_all.sh --access public"
},
"repository": {
"type": "git",
Expand Down
11 changes: 0 additions & 11 deletions scripts/bump_all_versions.sh

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/bump_version.sh

This file was deleted.

33 changes: 0 additions & 33 deletions scripts/nextVersion.js

This file was deleted.

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 --access public
npm publish $@
popd > /dev/null
done
9 changes: 6 additions & 3 deletions scripts/setup_all_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ set -e

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

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
echo $dir
pushd $dir > /dev/null
echo $dir
if [ -f "./package.json" ]; then
echo "Removing existing package.json..."
rm "./package.json"
echo "package.json deleted from $dir"
fi
cp ../../package.json ./
repo_name=`echo $dir | sed 's:.*/::' | sed 's/_/-/g'`
echo Setting package.json on npm packages
echo $repo_name
Expand Down

0 comments on commit 4cce306

Please sign in to comment.