diff --git a/.github/workflows/automate-release.yml b/.github/workflows/automate-publish.yml similarity index 76% rename from .github/workflows/automate-release.yml rename to .github/workflows/automate-publish.yml index 7f462cb..7086443 100644 --- a/.github/workflows/automate-release.yml +++ b/.github/workflows/automate-publish.yml @@ -1,6 +1,6 @@ # 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_Release +name: Automate_Publish on: workflow_run: workflows: ["Automate_Tag"] @@ -11,18 +11,23 @@ jobs: runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/heads/master') steps: - - uses: actions/checkout@master + - 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/ - - run: npm install - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.npm_token }} - name: 'Get Previous tag' id: previoustag uses: "WyriHaximus/github-action-get-previous-tag@v1" + - run: npm install + - run: | + npm_tag="v$(npm dist-tags | sed -n 's/^.* \([0-9].[0-9].[0-9]\)$/\1/p')" + git_tag="$(git describe --abbrev=0)" + if [ "$npm_tag" != "$git_tag" ] ; then npm publish; fi + env: + NODE_AUTH_TOKEN: ${{ secrets.npm_token }} - name: 'Publish Release' uses: Roang-zero1/github-create-release-action@master with: diff --git a/.github/workflows/automate-tag.yml b/.github/workflows/automate-tag.yml index 41b3a10..bccdb32 100644 --- a/.github/workflows/automate-tag.yml +++ b/.github/workflows/automate-tag.yml @@ -9,7 +9,7 @@ jobs: matrix: node-version: [10.x, 12.x, 14.x] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2.2.0 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} @@ -24,7 +24,7 @@ jobs: !contains(github.event.head_commit.message, '[MAJOR]') && !contains(github.event.head_commit.message, '[MINOR]') steps: - - uses: actions/checkout@master + - uses: actions/checkout@v2.2.0 - uses: actions/setup-node@v1 with: node-version: 14 @@ -42,7 +42,7 @@ jobs: !contains(github.event.head_commit.message, '[MAJOR]') && contains(github.event.head_commit.message, '[MINOR]') steps: - - uses: actions/checkout@master + - uses: actions/checkout@v2.2.0 - uses: actions/setup-node@v1 with: node-version: 14 @@ -60,7 +60,7 @@ jobs: contains(github.event.head_commit.message, '[MAJOR]') && !contains(github.event.head_commit.message, '[MINOR]') steps: - - uses: actions/checkout@master + - uses: actions/checkout@v2.2.0 - uses: actions/setup-node@v1 with: node-version: 14