Skip to content

chore: configure Conventional Commits, Husky, and Changesets #10

chore: configure Conventional Commits, Husky, and Changesets

chore: configure Conventional Commits, Husky, and Changesets #10

Workflow file for this run

name: Preview & Publish all CLIs
on:
pull_request:
branches: [main]
types: [opened, reopened, synchronize]
push:
branches: [main]
env:
# relative paths to each CLI
WORKSPACES: |
create-db
create-pg
create-postgres
jobs:
preview:
if: github.event_name == 'pull_request'
name: 🚧 Preview release (PR #${{ github.event.number }})
runs-on: ubuntu-latest
steps:
- name: πŸ›ŽοΈ Checkout full history
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 🀐 Disable Husky
run: echo "HUSKY=0" >> $GITHUB_ENV
- name: πŸ“¦ Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: πŸ”§ Install dependencies
run: pnpm install
- name: ❌ Disable pnpm git‐checks
run: pnpm config set git-checks false
- name: πŸ”‘ Configure npm auth
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.CREATE_DB_TOKEN_NPM }}" > ~/.npmrc
- name: πŸš€ Publish PR-tagged previews
run: |
PRE_TAG="pr${{ github.event.number }}-${{ github.event.pull_request.head.ref }}"
for pkg in $WORKSPACES; do
echo "β€Ί publishing $pkg"
cd $pkg
# bump a unique prerelease
npm version prerelease \
--preid "$PRE_TAG" \
--no-git-tag-version
# publish under tag pr<N>
pnpm publish --access public --tag pr${{ github.event.number }}
cd - >/dev/null
done
- name: 🧹 Cleanup npm auth
run: rm -f ~/.npmrc
publish:
if: github.event_name == 'push'
needs: preview
name: πŸš€ Bump & publish real releases
runs-on: ubuntu-latest
steps:
- name: πŸ›ŽοΈ Checkout full & tags
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: true
- name: 🀐 Disable Husky
run: echo "HUSKY=0" >> $GITHUB_ENV
- name: πŸ“¦ Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: πŸ”§ Install dependencies
run: pnpm install
- name: πŸ”„ Bump versions & changelogs
run: pnpm changeset version
- name: πŸ’Ύ Commit & push version bump
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit -am "chore: version packages [skip ci]" || echo "no version changes"
git push origin main --follow-tags
- name: πŸ”‘ Configure npm auth
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.CREATE_DB_TOKEN_NPM }}" > ~/.npmrc
- name: πŸš€ Publish all real releases
run: |
for pkg in $WORKSPACES; do
echo "β€Ί publishing $pkg"
cd $pkg
pnpm publish --access public
cd - >/dev/null
done
- name: 🧹 Cleanup npm auth
run: rm -f ~/.npmrc