diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..38fab48 --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 }}