fix: remove needs #16
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: Release all CLIs & Deploy CF Workers | |
on: | |
workflow_dispatch: | |
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: | |
version: "pnpm changeset version --yes" | |
commit: "chore(release): bump [skip ci]" | |
commitMode: "git-cli" | |
createGithubReleases: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# π On merges to main: aggregate CHANGELOGs, publish CLIs & deploy Workers | |
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 | |
if [ "$pkg" != "create-db" ]; then | |
cp create-db/README.md "$pkg/README.md" | |
fi | |
done | |
- name: π Aggregate changelogs | |
id: aggregate | |
run: | | |
NEW_VERSION=$(jq -r '.version' create-db/package.json) | |
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV | |
echo "# Release v$NEW_VERSION" > AGGREGATED_CHANGELOG.md | |
for pkg in $WORKSPACES; do | |
echo "## $pkg" >> AGGREGATED_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 each CLI individually | |
run: | | |
for pkg in $WORKSPACES; do | |
echo "Publishing $pkgβ¦" | |
pnpm --filter "$pkg" publish --access public | |
done | |
# examples for CF Worker deploys, if/when you uncomment: | |
# - name: βοΈ Deploy create-db-worker (production) | |
# uses: cloudflare/wrangler-action@v3 | |
# with: β¦ | |
- name: π§Ή Cleanup npm auth | |
if: ${{ always() }} | |
run: rm -f ~/.npmrc |