|
| 1 | +name: 'Draft Release' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + channel: |
| 7 | + description: 'Release channel' |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - beta |
| 12 | + - production |
| 13 | + ref: |
| 14 | + description: |
| 15 | + 'Branch or tag to release from (default: development for beta, latest |
| 16 | + beta tag for production). Use for hotfixes.' |
| 17 | + required: false |
| 18 | + type: string |
| 19 | + dry-run: |
| 20 | + description: 'Generate notes without creating a release branch' |
| 21 | + required: false |
| 22 | + type: boolean |
| 23 | + default: false |
| 24 | + |
| 25 | +permissions: |
| 26 | + contents: write |
| 27 | + pull-requests: write |
| 28 | + |
| 29 | +jobs: |
| 30 | + draft-release: |
| 31 | + name: Draft Release |
| 32 | + runs-on: ubuntu-latest |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Checkout repository |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + fetch-depth: 0 |
| 39 | + fetch-tags: true |
| 40 | + ref: ${{ inputs.ref || github.event.repository.default_branch }} |
| 41 | + |
| 42 | + - name: Set up Node.js |
| 43 | + uses: actions/setup-node@v4 |
| 44 | + with: |
| 45 | + node-version-file: '.nvmrc' |
| 46 | + cache: yarn |
| 47 | + |
| 48 | + - name: Install dependencies |
| 49 | + run: yarn --frozen-lockfile |
| 50 | + |
| 51 | + - name: Determine previous and next versions |
| 52 | + id: version |
| 53 | + run: > |
| 54 | + yarn ts-node -P script/tsconfig.json script/draft-release/ci.ts |
| 55 | + version ${{ inputs.channel }} |
| 56 | +
|
| 57 | + - name: Generate release notes (beta only) |
| 58 | + id: notes |
| 59 | + if: ${{ inputs.channel == 'beta' }} |
| 60 | + uses: github/copilot-release-notes@v1 |
| 61 | + with: |
| 62 | + base-ref: release-${{ steps.version.outputs.previous }} |
| 63 | + head-ref: ${{ inputs.ref || 'development' }} |
| 64 | + instructions: .github/release-notes-instructions.md |
| 65 | + env: |
| 66 | + GITHUB_TOKEN: ${{ github.token }} |
| 67 | + COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} |
| 68 | + |
| 69 | + - name: Parse changelog entries |
| 70 | + id: changelog |
| 71 | + env: |
| 72 | + CHANNEL: ${{ inputs.channel }} |
| 73 | + RELEASE_NOTES: ${{ steps.notes.outputs.release-notes }} |
| 74 | + UNCERTAIN: ${{ steps.notes.outputs.uncertain-entries }} |
| 75 | + SKIPPED: ${{ steps.notes.outputs.skipped-prs }} |
| 76 | + PREVIOUS: ${{ steps.version.outputs.previous }} |
| 77 | + NEXT: ${{ steps.version.outputs.next }} |
| 78 | + run: | |
| 79 | + if [ "$CHANNEL" = "production" ]; then |
| 80 | + # Production: aggregate existing beta entries via shared script |
| 81 | + ENTRIES=$(yarn --silent ts-node -P script/tsconfig.json \ |
| 82 | + script/draft-release/ci.ts changelog-entries "$PREVIOUS") |
| 83 | + else |
| 84 | + # Beta: parse AI-generated notes, extracting [Tag] lines |
| 85 | + ENTRIES=$(echo "$RELEASE_NOTES" | grep -E '^\[' || true) |
| 86 | + ENTRIES=$(echo "$ENTRIES" | jq -c -R -s 'split("\n") | map(select(length > 0))') |
| 87 | + fi |
| 88 | +
|
| 89 | + # Write entries as single-line JSON to output |
| 90 | + echo "entries=$ENTRIES" >> "$GITHUB_OUTPUT" |
| 91 | + COUNT=$(echo "$ENTRIES" | jq 'length') |
| 92 | +
|
| 93 | + # Step summary |
| 94 | + if [ "$CHANNEL" = "production" ]; then |
| 95 | + echo "## Production Release Notes — $NEXT" >> "$GITHUB_STEP_SUMMARY" |
| 96 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 97 | + echo "Aggregated $COUNT entries from beta releases since $PREVIOUS:" >> "$GITHUB_STEP_SUMMARY" |
| 98 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 99 | + echo "$ENTRIES" | jq -r '.[]' >> "$GITHUB_STEP_SUMMARY" |
| 100 | + else |
| 101 | + echo "## Draft Release Notes — $NEXT" >> "$GITHUB_STEP_SUMMARY" |
| 102 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 103 | + echo "$RELEASE_NOTES" >> "$GITHUB_STEP_SUMMARY" |
| 104 | +
|
| 105 | + if [ -n "$UNCERTAIN" ] && [ "$UNCERTAIN" != "[]" ] && [ "$UNCERTAIN" != "" ]; then |
| 106 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 107 | + echo "### ⚠️ Entries needing human review" >> "$GITHUB_STEP_SUMMARY" |
| 108 | + echo "$UNCERTAIN" >> "$GITHUB_STEP_SUMMARY" |
| 109 | + fi |
| 110 | +
|
| 111 | + if [ -n "$SKIPPED" ] && [ "$SKIPPED" != "[]" ] && [ "$SKIPPED" != "" ]; then |
| 112 | + SKIPPED_COUNT=$(echo "$SKIPPED" | jq 'length' 2>/dev/null || echo 0) |
| 113 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 114 | + echo "<details><summary>$SKIPPED_COUNT PRs excluded from notes</summary>" >> "$GITHUB_STEP_SUMMARY" |
| 115 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 116 | + echo "$SKIPPED" >> "$GITHUB_STEP_SUMMARY" |
| 117 | + echo "</details>" >> "$GITHUB_STEP_SUMMARY" |
| 118 | + fi |
| 119 | + fi |
| 120 | +
|
| 121 | + echo "📝 Parsed $COUNT changelog entries" |
| 122 | +
|
| 123 | + - name: Create release branch and commit |
| 124 | + if: ${{ inputs.dry-run == false }} |
| 125 | + env: |
| 126 | + CHANNEL: ${{ inputs.channel }} |
| 127 | + NEXT_VERSION: ${{ steps.version.outputs.next }} |
| 128 | + LATEST_BETA: ${{ steps.version.outputs.latest-beta }} |
| 129 | + REF_OVERRIDE: ${{ inputs.ref }} |
| 130 | + ENTRIES: ${{ steps.changelog.outputs.entries }} |
| 131 | + run: | |
| 132 | + BRANCH="releases/$NEXT_VERSION" |
| 133 | +
|
| 134 | + # Check if the release branch already exists |
| 135 | + if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then |
| 136 | + echo "::error::Branch $BRANCH already exists. Delete it first or use dry-run." |
| 137 | + exit 1 |
| 138 | + fi |
| 139 | +
|
| 140 | + git config user.name "github-actions[bot]" |
| 141 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 142 | +
|
| 143 | + if [ -n "$REF_OVERRIDE" ]; then |
| 144 | + # Hotfix: already on the correct ref from checkout step |
| 145 | + git checkout -b "$BRANCH" |
| 146 | + echo "🔧 Hotfix: branched from $REF_OVERRIDE" |
| 147 | + elif [ "$CHANNEL" = "production" ]; then |
| 148 | + # Production: branch from the latest beta tag |
| 149 | + if [ -z "$LATEST_BETA" ]; then |
| 150 | + echo "::error::Cannot create a production release branch because no latest beta version was found." |
| 151 | + exit 1 |
| 152 | + fi |
| 153 | + git checkout -b "$BRANCH" "release-$LATEST_BETA" |
| 154 | + else |
| 155 | + # Beta: already on development from checkout step |
| 156 | + git checkout -b "$BRANCH" |
| 157 | + fi |
| 158 | +
|
| 159 | + # Bump app/package.json and update changelog.json |
| 160 | + yarn --silent ts-node -P script/tsconfig.json \ |
| 161 | + script/draft-release/ci.ts prepare "$NEXT_VERSION" "$ENTRIES" |
| 162 | +
|
| 163 | + git add app/package.json changelog.json |
| 164 | + git commit -m "Draft release $NEXT_VERSION" |
| 165 | +
|
| 166 | + - name: Push release branch |
| 167 | + if: ${{ inputs.dry-run == false }} |
| 168 | + env: |
| 169 | + NEXT_VERSION: ${{ steps.version.outputs.next }} |
| 170 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 171 | + run: | |
| 172 | + git push origin "releases/$NEXT_VERSION" |
| 173 | + echo "✅ Pushed releases/$NEXT_VERSION — release-pr.yml will create the draft PR" |
0 commit comments