chore: configure Conventional Commits, Husky, and Changesets #12
This file contains hidden or 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: Preview & Publish all CLIs | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- reopened | |
- synchronize | |
push: | |
branches: | |
- main | |
env: | |
# each folder under the repo root that contains one of your CLIs | |
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 }}-${{ github.run_id }}" | |
for pkg in $WORKSPACES; do | |
echo "βΊ publishing $pkg@$PRE_TAG" | |
cd $pkg | |
npm version prerelease \ | |
--preid "$PRE_TAG" \ | |
--no-git-tag-version | |
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 & generate 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 |