Skip to content

Publish

Publish #313

Workflow file for this run

name: Publish
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
release-type:
description: 'Release type (one of): patch, minor, major'
required: true
permissions: write-all
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-and-publish:
# The type of runner that the job will run on
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: '18.x'
registry-url: https://registry.npmjs.org/
- name: Git configuration
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
- name: Install dependencies
run: yarn install --pure-lockfile
- name: Build
run: yarn build
- name: Unit tests
run: yarn test:unit
- name: Bump release version
run: |
echo "NEW_VERSION=$(npm --no-git-tag-version version $RELEASE_TYPE)" >> $GITHUB_ENV
echo "RELEASE_TAG=latest" >> $GITHUB_ENV
env:
RELEASE_TYPE: ${{ github.event.inputs.release-type }}
- name: Commit report
run: |
git commit -am "chore: release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
- name: Publish
run: npm publish --tag ${{ env.RELEASE_TAG }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}
- name: Push changes to repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin && git push --tags