Skip to content

update package-lock #624

update package-lock

update package-lock #624

name: test-and-publish
on:
- push
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 19.7
- run: npm ci --legacy-peer-deps
- run: npm run check
- uses: actions/upload-artifact@v2
with:
name: build
path: dist
env:
CI: true
publish:
name: publish
runs-on: ubuntu-latest
needs: build-and-test
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 19.7
- run: echo ::set-output name=CURRENT_VERSION::$(node -p "require(\"./package.json\").version")
id: current-version
- if: github.ref == 'refs/heads/master'
run: echo ::set-output name=VERSION_INFO::$(npm view $(node -p "require(\"./package.json\").name")@=${{ steps.current-version.outputs.CURRENT_VERSION }})
id: version-was-changed
- uses: actions/download-artifact@v2
# need to publish if the branch isn't master, or it is master and the version in package.json hasn't been published yet
if: github.ref != 'refs/heads/master' || steps.version-was-changed.outputs.VERSION_INFO == ''
with:
name: build
path: dist
# publish canary version on every push to every branch except master
- name: canary version
if: github.ref != 'refs/heads/master'
run: npm version ${{ steps.current-version.outputs.CURRENT_VERSION }}-$GITHUB_SHA --git-tag-version false
- name: canary publish
if: github.ref != 'refs/heads/master'
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
tag: canary
# publish & github release if master, and the version in package.json was changed
- name: publish
if: github.ref == 'refs/heads/master' && steps.version-was-changed.outputs.VERSION_INFO == ''
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
- run: echo ::set-output name=PACKAGE::$(npm pack)
id: package
if: github.ref == 'refs/heads/master' && steps.version-was-changed.outputs.VERSION_INFO == ''
- uses: marvinpinto/action-automatic-releases@v1.2.1
if: github.ref == 'refs/heads/master' && steps.version-was-changed.outputs.VERSION_INFO == ''
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
files: ${{ steps.package.outputs.PACKAGE }}
automatic_release_tag: ${{ steps.current-version.outputs.CURRENT_VERSION }}