Skip to content

Merge pull request #9 from prisma/patch-3 #7

Merge pull request #9 from prisma/patch-3

Merge pull request #9 from prisma/patch-3 #7

Workflow file for this run

name: Release all CLIs & Deploy CF Workers
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
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: πŸ”„ Version & changelogs via Changesets
uses: changesets/action@v1
with:
# run the version script
version: "pnpm changeset version --yes"
# commit and push back into the PR branch
commit: "chore(release): bump [skip ci]"
commitMode: "git-cli"
# 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
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: πŸ”§ Install jq
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: πŸ“„ Copy README to child CLIs
run: |
for pkg in $WORKSPACES; do
cp create-db/README.md "$pkg/README.md"
done
- name: πŸ“‘ Aggregate changelogs
id: aggregate
run: |
# pull the new version out of package.json
NEW_VERSION=$(jq -r '.version' create-db/package.json)
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
# header for the release
echo "# Release v$NEW_VERSION" > AGGREGATED_CHANGELOG.md
for pkg in $WORKSPACES; do
echo "## $pkg" >> AGGREGATED_CHANGELOG.md
# grab only the lines under ## $NEW_VERSION in each CHANGELOG.md
sed -n "/^## $NEW_VERSION/,/^## /p" $pkg/CHANGELOG.md \
| sed '1d;$d' \
>> 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