diff --git a/.changeset/github-releases.md b/.changeset/github-releases.md new file mode 100644 index 0000000..7c498fd --- /dev/null +++ b/.changeset/github-releases.md @@ -0,0 +1,5 @@ +--- +"eggdrop": patch +--- + +Rename promote-to-main workflow to auto-promote-and-release and add automatic GitHub Release creation. Releases are created with version tags (v0.x.x) and changelog content extracted from CHANGELOG.md. diff --git a/.claude/settings.local.json b/.claude/settings.local.json index a10629d..2e4f52f 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -30,7 +30,9 @@ "Bash(pnpm changeset:*)", "Bash(source ~/.nvm/nvm.sh)", "Bash(nvm use:*)", - "Bash(pnpm exec playwright test:*)" + "Bash(pnpm exec playwright test:*)", + "Bash(git push:*)", + "Bash(npm install:*)" ], "deny": [], "ask": [] diff --git a/.github/workflows/auto-promote-and-release.yml b/.github/workflows/auto-promote-and-release.yml new file mode 100644 index 0000000..71dbb08 --- /dev/null +++ b/.github/workflows/auto-promote-and-release.yml @@ -0,0 +1,91 @@ +# Automatically merges dev into main after a "Version Packages" PR is merged +# Creates a GitHub Release with changelog, then Vercel auto-deploys main to production +name: Auto Promote and Release + +on: + pull_request: + types: [closed] + branches: [dev] + # Keep manual trigger as backup + workflow_dispatch: + +jobs: + promote-and-release: + name: Promote to main and create release + runs-on: ubuntu-latest + # Only run if PR was merged (not just closed) AND is a Version Packages PR + # For workflow_dispatch, always run + if: > + github.event_name == 'workflow_dispatch' || + (github.event.pull_request.merged == true && + contains(github.event.pull_request.title, 'Version Packages')) + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Configure Git + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Merge dev into main + run: | + git checkout main + git pull origin main + git merge origin/dev --no-edit + git push origin main + + - name: Get version from package.json + id: get-version + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT + + - name: Check if tag exists + id: tag-check + run: | + if git rev-parse "v${{ steps.get-version.outputs.version }}" >/dev/null 2>&1; then + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + + - name: Create and push tag + if: steps.tag-check.outputs.exists == 'false' + run: | + git tag "v${{ steps.get-version.outputs.version }}" + git push origin "v${{ steps.get-version.outputs.version }}" + + - name: Extract changelog for this version + if: steps.tag-check.outputs.exists == 'false' + id: changelog + run: | + VERSION="${{ steps.get-version.outputs.version }}" + # Extract content between this version header and the next version header + CHANGELOG=$(sed -n "/^## ${VERSION}$/,/^## [0-9]/p" CHANGELOG.md | sed '$d' | tail -n +2) + echo "content<> $GITHUB_OUTPUT + echo "$CHANGELOG" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create GitHub Release + if: steps.tag-check.outputs.exists == 'false' + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ steps.get-version.outputs.version }} + name: v${{ steps.get-version.outputs.version }} + body: ${{ steps.changelog.outputs.content }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Summary + run: | + echo "✅ Successfully merged dev into main" + echo "🚀 Vercel will now deploy to production" + if [ "${{ steps.tag-check.outputs.exists }}" == "false" ]; then + echo "📦 Created GitHub Release v${{ steps.get-version.outputs.version }}" + else + echo "⏭️ Skipped release creation (tag v${{ steps.get-version.outputs.version }} already exists)" + fi diff --git a/.github/workflows/promote-to-main.yml b/.github/workflows/promote-to-main.yml deleted file mode 100644 index 3b7842a..0000000 --- a/.github/workflows/promote-to-main.yml +++ /dev/null @@ -1,46 +0,0 @@ -# Automatically merges dev into main after a "Version Packages" PR is merged -# This completes the release process - Vercel will auto-deploy main to production -name: Promote to Main - -on: - pull_request: - types: [closed] - branches: [dev] - # Keep manual trigger as backup - workflow_dispatch: - -jobs: - promote: - name: Merge dev to main - runs-on: ubuntu-latest - # Only run if PR was merged (not just closed) AND is a Version Packages PR - # For workflow_dispatch, always run - if: > - github.event_name == 'workflow_dispatch' || - (github.event.pull_request.merged == true && - contains(github.event.pull_request.title, 'Version Packages')) - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Configure Git - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - - - name: Merge dev into main - run: | - git checkout main - git pull origin main - git merge origin/dev --no-edit - git push origin main - - - name: Summary - run: | - echo "✅ Successfully merged dev into main" - echo "🚀 Vercel will now deploy to production"