Skip to content

Create release.yml

Create release.yml #1

Workflow file for this run

name: Publish Package to npmjs
run-name: ${{ github.actor }} publish to npm 🚀
on:
push:
tags:
- "v*.*.*"
jobs:
# Then release to npm
build:
name: Lint and build
runs-on: ubuntu-latest
needs: [build-test] # Require standard CI steps to pass before publishing
steps:
- name: Checkout repo
uses: actions/checkout@v4
# Set up .npmrc file to publish to npm. This also allows NODE_AUTH_TOKEN
# to work below.
- name: Install Nodejs
uses: actions/setup-node@v4
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
- name: Setup Yarn in Node
uses: actions/setup-node@v4
with:
cache: "yarn" # uses the system node, which was updated prior.
- name: Install dependencies
run: yarn
- name: Lint and clean code
run: yarn lint
- name: Build
run: yarn build
# Then release to npm
release:
if: ${{ github.ref == 'refs/heads/main' }}
name: Publish
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Needed for https://docs.npmjs.com/generating-provenance-statements
strategy:
matrix:
node-version: [18]
needs: [build] # Require standard CI steps to pass before publishing
steps:
- name: Checkout repo
run: echo "${{ github.event_name }} on ${{ github.ref }}."
- name: Checkout repo
uses: actions/checkout@v4
# Set up .npmrc file to publish to npm. This also allows NODE_AUTH_TOKEN
# to work below.
- name: Install Nodejs
uses: actions/setup-node@v4
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
- name: Setup Yarn in Node
uses: actions/setup-node@v4
with:
cache: "yarn" # uses the system node, which was updated prior.
- run: yarn publish --provenance
uses: ./
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}