automatically publish to npm #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v3 | |
- name: Install Node.js and Yarn | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: yarn | |
registry-url: "https://registry.npmjs.org" | |
- name: Install dependencies | |
run: yarn | |
- name: Lint the code | |
run: yarn lint | |
- name: Build release artifact | |
run: yarn build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-artifact | |
path: | | |
dist | |
package.json | |
- name: Test publish | |
run: yarn publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
release: | |
needs: build | |
# when merge to main and not a fork | |
if: github.repository == 'hivivo/windows-reg' && github.event_name == 'push' | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v3 | |
- name: Install Node.js and Yarn | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: yarn | |
registry-url: "https://registry.npmjs.org" | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-artifact | |
- name: Bump version | |
uses: 'phips28/gh-action-bump-version@master' | |
with: | |
tag-prefix: 'v' | |
- name: Release to NPM registry | |
run: yarn publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |