Skip to content

Commit

Permalink
Update npm-publish.yml and package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
milespetrov committed Mar 25, 2024
1 parent fdd7f5c commit 85077a1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions .github/workflows/npm-publish.yml
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 }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ramp",
"name": "ramp-pcar",
"version": "4.5.0-beta",
"description": "RAMP4 - The Reusable Accessible Mapping Platform, is a Javascript based web mapping platform that provides a reusable, responsive and WCAG 2.1 AA compliant common viewer for the Government of Canada. ",
"type": "module",
Expand Down

0 comments on commit 85077a1

Please sign in to comment.