forked from ramp4-pcar4/ramp4-pcar4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update npm-publish.yml and package.json
- Loading branch information
1 parent
fdd7f5c
commit 85077a1
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Publish to npm | ||
|
||
on: | ||
workflow_run: | ||
workflows: ['Name of your build workflow'] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'milespetrov/ramp4-pcar4' && github.event.workflow_run.event == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: latest | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- name: Grab the build files from the cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: dist | ||
key: dist-${{ format('{0}-{1}', github.ref_name, github.sha) }} | ||
|
||
- name: Update version in package.json | ||
run: | | ||
TAG_VERSION=${GITHUB_REF#refs/tags/v} | ||
PACKAGE_VERSION=$(node -p "require('./package.json').version") | ||
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then | ||
npm version --allow-same-version --no-git-tag-version $TAG_VERSION | ||
echo "::warning::Tag version ($TAG_VERSION) did not match package.json version ($PACKAGE_VERSION). Updated package.json to $TAG_VERSION." | ||
else | ||
echo "::info::Tag version ($TAG_VERSION) matches package.json version ($PACKAGE_VERSION)." | ||
fi | ||
- name: Publish | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters