chore(release): 1.4.16 #218
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| id-token: write | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| release: | |
| name: Release to NPM | |
| if: startsWith(github.event.head_commit.message, 'chore(release):') | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract version from commit message | |
| id: version | |
| run: | | |
| FIRST_LINE=$(echo "${{ github.event.head_commit.message }}" | head -n 1) | |
| VERSION=$(echo "$FIRST_LINE" | sed -E 's/^chore\(release\): ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Releasing version: $VERSION" | |
| - name: Validate version format | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Error: Invalid version format '$VERSION'. Expected semver (x.y.z)" | |
| exit 1 | |
| fi | |
| - name: Check if version already exists | |
| id: check-version | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if npm view create-better-fullstack@$VERSION version 2>/dev/null; then | |
| echo "Version $VERSION already exists on NPM" | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Version $VERSION is new" | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create and push tag | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| git config --local user.email "amanvarshney.work@gmail.com" | |
| git config --local user.name "Aman Varshney" | |
| if ! git rev-parse "v$VERSION" >/dev/null 2>&1; then | |
| git tag -a "v$VERSION" -m "Release v$VERSION" | |
| git push --tags | |
| else | |
| echo "Tag v$VERSION already exists, skipping" | |
| fi | |
| - name: Setup Bun | |
| if: steps.check-version.outputs.exists == 'false' | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Cache Dependencies | |
| if: steps.check-version.outputs.exists == 'false' | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| node_modules | |
| ~/.bun/install/cache | |
| key: release-${{ runner.os }}-bun-${{ hashFiles('bun.lock') }} | |
| restore-keys: | | |
| release-${{ runner.os }}-bun- | |
| - name: Install Dependencies | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: bun install --frozen-lockfile | |
| - name: Run Release Verification | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: bun run test:release | |
| - name: Create GitHub Release | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if ! gh release view "v$VERSION" >/dev/null 2>&1; then | |
| bunx changelogithub | |
| else | |
| echo "Release v$VERSION already exists, skipping" | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update types package version | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| cd packages/types | |
| jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json | |
| - name: Build types package | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: cd packages/types && bun run build | |
| - name: Publish types to NPM | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: cd packages/types && bun publish --access public | |
| env: | |
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| BTS_TELEMETRY: 1 | |
| CONVEX_INGEST_URL: ${{ secrets.CONVEX_INGEST_URL }} | |
| - name: Update template-generator package version and types dependency | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| cd packages/template-generator | |
| jq --arg v "$VERSION" --arg dep "^$VERSION" '.version = $v | .dependencies["@better-fullstack/types"] = $dep' package.json > tmp.json && mv tmp.json package.json | |
| - name: Build template-generator package | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: cd packages/template-generator && bun run build | |
| - name: Publish template-generator to NPM | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: cd packages/template-generator && bun publish --access public | |
| env: | |
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| BTS_TELEMETRY: 1 | |
| CONVEX_INGEST_URL: ${{ secrets.CONVEX_INGEST_URL }} | |
| - name: Update CLI types and template-generator dependencies and version | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| cd apps/cli | |
| jq --arg version "$VERSION" --arg dep "^$VERSION" '.version = $version | .dependencies["@better-fullstack/types"] = $dep | .dependencies["@better-fullstack/template-generator"] = $dep' package.json > tmp.json && mv tmp.json package.json | |
| - name: Build CLI | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: cd apps/cli && bun run build | |
| env: | |
| BTS_TELEMETRY: 1 | |
| CONVEX_INGEST_URL: ${{ secrets.CONVEX_INGEST_URL }} | |
| - name: Update create-bfs alias package version | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| cd packages/create-bfs | |
| jq --arg v "$VERSION" --arg dep "^$VERSION" '.version = $v | .dependencies["create-better-fullstack"] = $dep' package.json > tmp.json && mv tmp.json package.json | |
| - name: Publish CLI to NPM | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: cd apps/cli && bun publish --access public | |
| env: | |
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| BTS_TELEMETRY: 1 | |
| CONVEX_INGEST_URL: ${{ secrets.CONVEX_INGEST_URL }} | |
| - name: Publish create-bfs alias to NPM | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: cd packages/create-bfs && bun publish --access public | |
| env: | |
| NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| BTS_TELEMETRY: 1 | |
| CONVEX_INGEST_URL: ${{ secrets.CONVEX_INGEST_URL }} | |
| - name: Release Summary | |
| if: steps.check-version.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| echo "## Release v$VERSION Complete!" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Published Packages" >> $GITHUB_STEP_SUMMARY | |
| echo "- [create-better-fullstack@$VERSION](https://www.npmjs.com/package/create-better-fullstack/v/$VERSION)" >> $GITHUB_STEP_SUMMARY | |
| echo "- [create-bfs@$VERSION](https://www.npmjs.com/package/create-bfs/v/$VERSION)" >> $GITHUB_STEP_SUMMARY | |
| echo "- [@better-fullstack/types@$VERSION](https://www.npmjs.com/package/@better-fullstack/types/v/$VERSION)" >> $GITHUB_STEP_SUMMARY | |
| echo "- [@better-fullstack/template-generator@$VERSION](https://www.npmjs.com/package/@better-fullstack/template-generator/v/$VERSION)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### GitHub Release" >> $GITHUB_STEP_SUMMARY | |
| echo "[v$VERSION](https://github.com/${{ github.repository }}/releases/tag/v$VERSION)" >> $GITHUB_STEP_SUMMARY |