Publish package #14
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: Publish package | |
on: | |
workflow_dispatch: | |
inputs: | |
package: | |
type: choice | |
required: true | |
description: 'Package to publish' | |
default: 'eslint-config-react' | |
options: | |
- eslint-config-react | |
- prettier-config-react | |
push: | |
tags: | |
- 'eslint-config-react@v*.*.*' | |
- 'prettier-config-react@v*.*.*' | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
publish: | |
strategy: | |
matrix: | |
registry: | |
- url: https://registry.npmjs.org | |
token_secret: NPM_TOKEN | |
- url: https://npm.pkg.github.com | |
token_secret: GITHUB_TOKEN | |
runs-on: ubuntu-latest | |
steps: | |
- id: get-package | |
shell: bash | |
run: | | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
# manual dispatches get package from the input | |
package=${{ github.event.inputs.package }} | |
else | |
# else get the package from the tag | |
package=$(echo ${{github.ref_name}} | cut -d@ -f1) | |
fi | |
echo "package=$package" >> $GITHUB_OUTPUT | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 8 | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
cache: pnpm | |
registry-url: ${{ matrix.registry.url }} | |
scope: '@invoke-ai' | |
- name: Version bump | |
working-directory: 'packages/${{steps.get-package.outputs.package}}' | |
# only if manual workflow dispatch and not on a tag | |
if: github.event_name == 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/') | |
run: npm version prepatch --preid=$(git rev-parse --short HEAD) --no-git-tag-version | |
- name: Publish | |
shell: bash | |
run: | | |
# manual workflow dispatches are tagged as pre-release - all releases should go through proper tagging process | |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
FLAGS="--tag pre" | |
fi | |
pnpm publish --access public --no-git-checks $FLAGS | |
working-directory: 'packages/${{steps.get-package.outputs.package}}' | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets[matrix.registry.token_secret] }} |