Publish to GitHub npm Registry (minor) #8
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: '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 | |
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 |