Skip to content

Commit

Permalink
chore(ci-cd): add release publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
abouroubi authored Nov 19, 2020
1 parent db79b2b commit 0bd2ab2
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# This is a basic workflow to help you get started with Actions

name: Release to GitHub and Publish to NPM

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"

build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'version bump to')"
outputs:
tag: ${{ steps.tag_name.outputs.TAG }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12

- name: Automated Version Bump
uses: phips28/gh-action-bump-version@master

- run: npm ci --ignore-scripts
- run: npm run build --if-present
- name: Export TAG Parameter
id: tag_name
run: |
echo ::set-output name=TAG::`cat package.json | jq -r .version`
shell: bash


realease:
needs: [build]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12
- name: GH Release
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ needs.build.outputs.tag }}"

publish:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- name: Publish
run: |
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm publish --ignore-scripts
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 0bd2ab2

Please sign in to comment.