Skip to content

Automate_Publish

Automate_Publish #1189

# 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/checkout@v2.2.0
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/actions-yarn@v3.0.0
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 }}