Skip to content

pkg: Publish to npm #25

pkg: Publish to npm

pkg: Publish to npm #25

Workflow file for this run

name: 'pkg: Publish to npm'
on:
workflow_dispatch:
inputs:
version:
description: 'Semantic Version'
required: true
type: choice
options:
- patch
- minor
- major
- calculate
jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
steps:
- name: 'πŸ›’ Checkout Code'
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_BOT_TOKEN }}
- name: '🟒 Use Node.js'
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: 'πŸ”Ό Increment Version'
if: ${{ inputs.version != 'calculate' }}
run: yarn version ${{ inputs.version }}
- name: '#️⃣ Get Version'
uses: actions/github-script@v7
if: ${{ inputs.version != 'calculate' }}
id: version
with:
result-encoding: string
retries: 3
script: |
const fs = require('fs');
const pj = JSON.parse(fs.readFileSync('${{ github.workspace }}/package.json'));
return pj.version;
- name: 'πŸ’Ύ Commit Incremented Version'
if: ${{ inputs.version != 'calculate' }}
run: |
git config --local user.email "${{ secrets.GH_BOT_EMAIL }}"
git config --local user.name "${{ secrets.GH_BOT_NAME }}"
git add package.json
git commit -am "[πŸ€– release]: ${{ steps.version.outputs.result }} (${{ inputs.version }})"
git push origin HEAD --force
- name: 'πŸ“ Generate Release Notes (user-input)'
uses: toolmantim/release-drafter@v6
if: ${{ inputs.version != 'calculate' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: v${{ steps.version.outputs.result }}
publish: true
- name: 'πŸ“ Generate Release Notes (calculated)'
uses: toolmantim/release-drafter@v6
if: ${{ inputs.version == 'calculate' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
publish: true
- name: 'πŸ—οΈ Build'
run: yarn build
- name: Setup .yarnrc.yml
run: |
yarn config set npmScopes.joggr.npmRegistryServer "https://registry.npmjs.org"
yarn config set npmScopes.joggr.npmAlwaysAuth true
yarn config set npmScopes.joggr.npmAuthToken $NPM_AUTH_TOKEN
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH }}
- name: '🚒 Publish'
run: yarn npm publish --access public