fix: remove needs #24
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
# .github/workflows/release.yml | |
name: Release CLIs & Deploy CF Workers | |
on: | |
pull_request: | |
branches: [main] | |
types: [opened, synchronize] | |
push: | |
tags: | |
- "v*.*.*" | |
workflow_dispatch: | |
env: | |
WORKSPACES: create-db create-pg create-postgres | |
HUSKY: 0 | |
jobs: | |
#======================================================================== | |
# 1️⃣ Dry-run each CLI on PRs | |
#======================================================================== | |
dry-run: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🛎️ Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: 📦 Setup pnpm v8 | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: 🔧 Install dependencies | |
run: pnpm install --workspace-root | |
- name: 📄 Copy root README into each CLI | |
run: | | |
for pkg in $WORKSPACES; do | |
cp README.md "$pkg/README.md" | |
done | |
- name: 🚨 Dry-run publish each CLI | |
run: | | |
set -e | |
for pkg in $WORKSPACES; do | |
echo "⏳ Dry-running $pkg..." | |
cd "$pkg" | |
npm publish --dry-run | |
cd - | |
done | |
#======================================================================== | |
# 2️⃣ Real publish on tag pushes | |
#======================================================================== | |
release: | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
needs: dry-run | |
steps: | |
- name: 🛎️ Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: 📦 Setup pnpm v8 | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: 🔧 Install dependencies (strict lockfile) | |
run: pnpm install --workspace-root --frozen-lockfile | |
- name: 🔧 Install jq | |
run: sudo apt-get update && sudo apt-get install -y jq | |
- name: 📄 Copy root README into each CLI | |
run: | | |
for pkg in $WORKSPACES; do | |
cp README.md "$pkg/README.md" | |
done | |
- name: 🔑 Configure npm auth | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.CREATE_DB_TOKEN_NPM }}" > ~/.npmrc | |
- name: 🚀 Publish each CLI sequentially | |
run: | | |
set -e | |
TAG="${GITHUB_REF#refs/tags/}" | |
for pkg in $WORKSPACES; do | |
echo "⏳ Publishing $pkg@$TAG…" | |
cd "$pkg" | |
npm publish --access public | |
cd - | |
done | |
- name: 🚩 Create GitHub Release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ github.ref_name }} | |
release_name: Release ${{ github.ref_name }} | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 🧹 Cleanup npm auth | |
if: ${{ always() }} | |
run: rm -f ~/.npmrc |