45 lines
1.3 KiB
YAML
45 lines
1.3 KiB
YAML
|
name: publish-and-tag
|
||
|
env:
|
||
|
CI: true
|
||
|
on:
|
||
|
push:
|
||
|
branches:
|
||
|
- master
|
||
|
jobs:
|
||
|
publish-to-npm:
|
||
|
runs-on: ubuntu-latest
|
||
|
steps:
|
||
|
- name: checkout
|
||
|
uses: actions/checkout@v2
|
||
|
- name: setup Node
|
||
|
uses: actions/setup-node@v2
|
||
|
with:
|
||
|
node-version: 14.x
|
||
|
registry-url: 'https://registry.npmjs.org'
|
||
|
- name: install
|
||
|
run: npm install
|
||
|
- name: test
|
||
|
run: npm test
|
||
|
# Publish to npm if this version is not published
|
||
|
- name: publish
|
||
|
run: npm run publish:npm
|
||
|
env:
|
||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
||
|
create-tag:
|
||
|
runs-on: ubuntu-latest
|
||
|
needs: publish-to-npm
|
||
|
steps:
|
||
|
- name: checkout
|
||
|
uses: actions/checkout@v2
|
||
|
# Push tag to GitHub if package.json version's tag is not tagged
|
||
|
- name: package-version
|
||
|
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
|
||
|
- name: package-version-to-git-tag
|
||
|
uses: pkgdeps/git-tag-action@v2
|
||
|
with:
|
||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||
|
github_repo: ${{ github.repository }}
|
||
|
version: ${{ env.PACKAGE_VERSION }}
|
||
|
git_commit_sha: ${{ github.sha }}
|
||
|
git_tag_prefix: "v"
|