Skip to content

fix: same dir in the workflow #8

fix: same dir in the workflow

fix: same dir in the workflow #8

Workflow file for this run

name: Release all CLIs & Deploy CF Workers
# Add permissions for writing contents (releases, tags, commits) and PRs
permissions:
contents: write
pull-requests: write
on:
pull_request:
branches: [main]
types: [opened, synchronize]
push:
branches: [main]
env:
WORKSPACES: create-db create-pg create-postgres
jobs:
# πŸ’Ύ On PRs: bump package.json versions & CHANGELOGs via Changesets
version:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: πŸ›ŽοΈ Checkout full & tags
# Updated to v4 for the latest features and security
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
- name: 🀐 Disable Husky
run: echo "HUSKY=0" >> $GITHUB_ENV
- name: πŸ“¦ Setup pnpm
# Updated to v4 for the latest features and security
uses: pnpm/action-setup@v4
with:
version: 8
- name: πŸ”§ Install dependencies
# Using --frozen-lockfile is a best practice in CI to ensure reproducibility
run: pnpm install --frozen-lockfile
- name: πŸ”„ Version & changelogs via Changesets
uses: changesets/action@v1
with:
# This command creates the version bump commit
version: "pnpm changeset version"
# Custom commit message for the version bump
commit: "chore(release): bump versions"
# Don’t create a GitHub release on a PR run
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# πŸš€ On merges to main: aggregate CHANGELOGs, tag & publish
publish:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: πŸ›ŽοΈ Checkout full & tags
# Updated to v4
uses: actions/checkout@v4
with:
fetch-depth: 0
# Credentials are not needed for this job as it doesn't push commits
persist-credentials: false
- name: 🀐 Disable Husky
run: echo "HUSKY=0" >> $GITHUB_ENV
- name: πŸ“¦ Setup pnpm
# Updated to v4
uses: pnpm/action-setup@v4
with:
version: 8
- name: πŸ”§ Install dependencies
run: pnpm install --frozen-lockfile
- name: πŸ”§ Install jq
# Combine update and install into a single layer
run: sudo apt-get update && sudo apt-get install -y jq
- name: πŸ“„ Copy README to child CLIs
# FIX: Added a condition to prevent copying a file to its own location
run: |
for pkg in $WORKSPACES; do
if [ "$pkg" != "create-db" ]; then
cp create-db/README.md "$pkg/README.md"
fi
done
- name: πŸ“‘ Aggregate changelogs
id: aggregate
run: |
# Pull the new version out of package.json from the primary workspace
NEW_VERSION=$(jq -r '.version' create-db/package.json)
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
# Header for the release body
echo "# Release v$NEW_VERSION" > AGGREGATED_CHANGELOG.md
echo "" >> AGGREGATED_CHANGELOG.md
for pkg in $WORKSPACES; do
echo "## \`$pkg\`" >> AGGREGATED_CHANGELOG.md
# IMPROVEMENT: Use a more robust awk command to extract changelog entries.
# This correctly handles cases where the version is the last one in the file.
awk -v ver="## $NEW_VERSION" '
$0 ~ ver { found=1; next }
/^## / { found=0 }
found { print }
' "$pkg/CHANGELOG.md" >> AGGREGATED_CHANGELOG.md
echo "" >> AGGREGATED_CHANGELOG.md
done
- name: 🚩 Create GitHub Release
uses: actions/create-release@v1
with:
tag_name: v${{ env.NEW_VERSION }}
release_name: Release v${{ env.NEW_VERSION }}
body_path: AGGREGATED_CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: πŸ”‘ Configure npm auth
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.CREATE_DB_TOKEN_NPM }}" > ~/.npmrc
- name: πŸš€ Publish CLIs
run: pnpm -r --filter "{create-db,create-pg,create-postgres}" publish --access public
# β€” CF production deploys commented out β€”
# - name: ☁️ Deploy create-db-worker (production)
# uses: cloudflare/wrangler-action@v3
# ...
- name: 🧹 Cleanup npm auth
if: ${{ always() }}
run: rm -f ~/.npmrc