-
Notifications
You must be signed in to change notification settings - Fork 17
38 lines (38 loc) · 1.33 KB
/
automate-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: Automate_Publish
on:
workflow_run:
workflows: ["Automate_Tag"]
types:
- completed
jobs:
auto-publish:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/master')
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- uses: borales/[email protected]
with:
cmd: install --frozen-lockfile
- run: |
npm_tag="v$(npm dist-tags | cut -d' ' -f 2)"
git_tag="$(git describe --tags | cut -d'-' -f 1)"
if [ "$npm_tag" != "$git_tag" ] ; then npm publish; fi
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_bot_token }}
- name: 'Publish Release'
uses: Roang-zero1/github-create-release-action@master
with:
created_tag: ${{ steps.previoustag.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}