Skip to content

Publish to GitHub npm Registry (minor) #6

Publish to GitHub npm Registry (minor)

Publish to GitHub npm Registry (minor) #6

name: 'pkgs: Publish to internal npm registry'
run-name: 'Publish to GitHub npm Registry (${{ inputs.version }})'
on:
workflow_dispatch:
inputs:
version:
description: 'Semantic Version'
required: true
default: 'prerelease'
type: choice
options:
- patch
- minor
- major
- prerelease
jobs:
publish:
name: 'Publish to GitHub npm Registry'
runs-on: ubuntu-latest-4-cores
timeout-minutes: 15
steps:
- name: 'πŸ›’ Checkout Code'
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_BOT_TOKEN }}
- name: "𝌀 Enable Corepack"
run: corepack enable
- name: '🟒 Setup Node.js'
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://npm.pkg.github.com'
token: ${{ secrets.GH_BOT_TOKEN }}
scope: '@joggrdocs'
cache: 'yarn'
- name: 'πŸ“¦ Install packages'
run: yarn install
- name: 'πŸ”Ό Increment Version'
# We have to run with npm because yarn's update is based on "stableVersion" which is not what we want
run: yarn workspaces foreach --all exec npm version --no-git-tag-version --no-workspaces-update ${{ inputs.version }}
- name: '#️⃣ Get Version'
uses: actions/github-script@v7
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: 'πŸ—οΈ Build'
run: yarn turbo run build --filter="./packages/*"
- name: '🧢 Setup .yarnrc.yml'
run: 'yarn config set npmScopes.joggrdocs.npmAuthToken ${{ secrets.GH_BOT_TOKEN }}'
- name: '🚒 Publish'
run: yarn workspaces foreach -A --include "packages/*" npm publish --tolerate-republish --access restricted
- name: 'πŸ’Ύ Commit Incremented Version'
run: |
git config --local user.email "${{ secrets.GH_BOT_EMAIL }}"
git config --local user.name "${{ secrets.GH_BOT_NAME }}"
git add ./packages/*/package.json ./package.json
git commit -m "[πŸ€– npm-publish]: ${{ steps.version.outputs.result }} (${{ inputs.version }}) [skip-ci]"
git push origin HEAD --force
- name: 'πŸ“ Publish Release Notes'
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version: v${{ steps.version.outputs.result }}
publish: true