Skip to content

Commit

Permalink
Added a release script to prevent from republication
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Seydoux committed Jan 13, 2020
1 parent 00d203e commit f2bac9a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ jobs:
registry-url: https://npm.pkg.github.com/
scope: '@pmcb55'
- name: NPM install, test and publish
run: |
npm ci --registry https://npm.pkg.github.com/pmcb55 --prefix lit-vocab-term/lit-vocab-term-base/
npm test --prefix lit-vocab-term/lit-vocab-term-base/
cd lit-vocab-term/lit-vocab-term-base/ && npm publish --registry https://npm.pkg.github.com/pmcb55
# The test fallback in the last line prevents from blocking the other scripts when republishing
run: bash ./.github/workflows/release-if-updated.sh ./lit-vocab-term/lit-vocab-term-base
env:
NODE_AUTH_TOKEN: ${{ secrets.ACCESS_TOKEN }}

Expand All @@ -40,10 +38,7 @@ jobs:
registry-url: https://npm.pkg.github.com/
scope: '@pmcb55'
- name: NPM install, test and publish
run: |
npm ci --registry https://npm.pkg.github.com/pmcb55 --prefix lit-vocab-term/lit-vocab-term-rdf-ext/
npm test --prefix lit-vocab-term/lit-vocab-term-rdf-ext/
cd lit-vocab-term/lit-vocab-term-rdf-ext/ && npm publish --registry https://npm.pkg.github.com/pmcb55
run: bash ./.github/workflows/release-if-updated.sh ./lit-vocab-term/lit-vocab-term-rdf-ext
env:
NODE_AUTH_TOKEN: ${{ secrets.ACCESS_TOKEN }}

Expand All @@ -63,9 +58,6 @@ jobs:
registry-url: https://npm.pkg.github.com/
scope: '@pmcb55'
- name: NPM install, test and publish
run: |
npm ci --registry https://npm.pkg.github.com/pmcb55 --prefix lit-vocab-term/lit-vocab-term-rdflib/
npm test --prefix lit-vocab-term/lit-vocab-term-rdfrdflib/
cd lit-vocab-term/lit-vocab-term-rdflib/ && npm publish --registry https://npm.pkg.github.com/pmcb55
run: bash ./.github/workflows/release-if-updated.sh ./lit-vocab-term/lit-vocab-term-rdflib
env:
NODE_AUTH_TOKEN: ${{ secrets.ACCESS_TOKEN }}
13 changes: 13 additions & 0 deletions .github/workflows/release-if-updated.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This script expects the path to the module directory as an argument
cd $1
# Get the package name from the package.json file
packageName=`node -p "require('./package.json').name"`
publishedVersion=`npm view $packageName --registry https://npm.pkg.github.com version `
newVersion=`node -p "require('./package.json').version"`
# Only proceed if the version about to be published has not been published previously
if [ $newVersion != $publishedVersion ]
then
npm install --registry https://npm.pkg.github.com/pmcb55
npm test
npm publish --registry https://npm.pkg.github.com/pmcb55
fi

0 comments on commit f2bac9a

Please sign in to comment.