fix: create releases for manual version bumps #19
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 & Docs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| concurrency: ${{ github.workflow }}-${{ github.ref }} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| release: | |
| name: Version bump & deploy docs | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # Fetch full history of the current ref so git operations behave like locally | |
| fetch-depth: 0 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| # Explicitly set repository to ensure proper authentication | |
| repository: ${{ github.repository }} | |
| - name: Configure Git for authentication | |
| run: | | |
| git config --global url."https://${{ secrets.PAT_TOKEN }}@github.com/".insteadOf "https://github.com/" | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Ensure main branch is available | |
| run: | | |
| git fetch origin main | |
| git fetch --tags | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.0.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: "pnpm" | |
| - name: Install Dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Generate Prisma Client | |
| run: pnpm --filter=api db:generate | |
| - name: Build Packages | |
| run: pnpm build | |
| - name: Verify Versioning Setup | |
| run: pnpm verify:versioning | |
| - name: Create Release Pull Request or Version Bump | |
| id: changesets | |
| uses: changesets/action@v1 | |
| continue-on-error: true | |
| with: | |
| version: pnpm version | |
| commit: "chore: version packages" | |
| title: "chore: version packages" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
| - name: Get Version from Package.json | |
| id: version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Check if Release Tag Exists | |
| id: check_tag | |
| run: | | |
| TAG="v${{ steps.version.outputs.version }}" | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "tag_exists=true" >> $GITHUB_OUTPUT | |
| echo "Tag $TAG already exists" | |
| else | |
| echo "tag_exists=false" >> $GITHUB_OUTPUT | |
| echo "Tag $TAG does not exist, will create release" | |
| fi | |
| - name: Create GitHub Release | |
| if: steps.version.outputs.version != '' && steps.check_tag.outputs.tag_exists == 'false' | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| release_name: Release v${{ steps.version.outputs.version }} | |
| body: | | |
| See [Changelog](https://docs.dester.in/changelog) for details. | |
| Package changelogs: | |
| - [API](../blob/main/apps/api/CHANGELOG.md) | |
| - [CLI](../blob/main/packages/cli/CHANGELOG.md) | |
| - [Docs](../blob/main/apps/docs/CHANGELOG.md) | |
| draft: false | |
| prerelease: false | |
| # Build and deploy docs to GitHub Pages for every push to main | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Build Docs | |
| run: pnpm turbo build --filter=docs | |
| - name: Upload Docs Artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./apps/docs/dist | |
| - name: Deploy Docs to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |