|
| 1 | +name: Bump Terminal.Gui |
| 2 | + |
| 3 | +# Keeps <TerminalGuiVersion> in Directory.Build.props tracking Terminal.Gui's |
| 4 | +# NuGet publishes. Policy: develop tracks TG's develop pre-releases (Editor is |
| 5 | +# a continuous canary for TG API churn); a stable Editor release requires a |
| 6 | +# stable pin (enforced by prepare-release.yml). |
| 7 | +# |
| 8 | +# Flow: |
| 9 | +# - Resolve the newest TG version on NuGet for the requested channel |
| 10 | +# (default: prerelease = newest overall; stable = newest without a `-`). |
| 11 | +# - If it differs from the current pin: bump, build, run the test suites. |
| 12 | +# - Green → commit directly to develop (push uses RELEASE_PAT so the push |
| 13 | +# triggers release.yml, publishing a new Editor pre-release and dispatching |
| 14 | +# downstream to clet). |
| 15 | +# - Red → push a `bump/terminal-gui-<version>` branch, open a PR so the |
| 16 | +# breakage is visible, and fail this run. |
| 17 | +# |
| 18 | +# Triggers: |
| 19 | +# - repository_dispatch `terminal-gui-published` (sent by gui-cs/Terminal.Gui's |
| 20 | +# publish workflow; payload: { "version": "2.4.6-develop.10" }) |
| 21 | +# - schedule: fallback poll, in case the dispatch is missing/not configured |
| 22 | +# - workflow_dispatch: manual, with channel selection (use channel=stable to |
| 23 | +# pin a stable TG ahead of an Editor stable release) |
| 24 | + |
| 25 | +on: |
| 26 | + repository_dispatch: |
| 27 | + types: [terminal-gui-published] |
| 28 | + schedule: |
| 29 | + - cron: '23 */6 * * *' |
| 30 | + workflow_dispatch: |
| 31 | + inputs: |
| 32 | + channel: |
| 33 | + description: 'Which TG stream to pin' |
| 34 | + required: true |
| 35 | + type: choice |
| 36 | + options: |
| 37 | + - prerelease |
| 38 | + - stable |
| 39 | + default: prerelease |
| 40 | + version: |
| 41 | + description: 'Explicit Terminal.Gui version (optional; overrides channel)' |
| 42 | + required: false |
| 43 | + type: string |
| 44 | + |
| 45 | +permissions: |
| 46 | + contents: write |
| 47 | + pull-requests: write |
| 48 | + |
| 49 | +concurrency: |
| 50 | + group: bump-terminal-gui |
| 51 | + cancel-in-progress: false |
| 52 | + |
| 53 | +jobs: |
| 54 | + bump: |
| 55 | + runs-on: ubuntu-latest |
| 56 | + env: |
| 57 | + GH_TOKEN: ${{ secrets.RELEASE_PAT }} |
| 58 | + # Terminal.Gui drivers skip real-terminal probing/IO on TTY-less runners. |
| 59 | + DisableRealDriverIO: "1" |
| 60 | + steps: |
| 61 | + - name: Checkout develop |
| 62 | + uses: actions/checkout@v5 |
| 63 | + with: |
| 64 | + ref: develop |
| 65 | + token: ${{ secrets.RELEASE_PAT }} |
| 66 | + |
| 67 | + - name: Configure Git |
| 68 | + run: | |
| 69 | + git config user.name "github-actions[bot]" |
| 70 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 71 | +
|
| 72 | + - name: Resolve target Terminal.Gui version |
| 73 | + id: resolve |
| 74 | + shell: bash |
| 75 | + run: | |
| 76 | + CURRENT=$(sed -n 's|.*<TerminalGuiVersion[^>]*>\(.*\)</TerminalGuiVersion>.*|\1|p' Directory.Build.props | head -1) |
| 77 | + if [ -z "$CURRENT" ]; then |
| 78 | + echo "::error::Could not read <TerminalGuiVersion> from Directory.Build.props." |
| 79 | + exit 1 |
| 80 | + fi |
| 81 | +
|
| 82 | + EXPLICIT="${{ github.event.inputs.version || github.event.client_payload.version }}" |
| 83 | + CHANNEL="${{ github.event.inputs.channel || 'prerelease' }}" |
| 84 | +
|
| 85 | + if [ -n "$EXPLICIT" ]; then |
| 86 | + TARGET="$EXPLICIT" |
| 87 | + else |
| 88 | + # Flat-container index is sorted ascending by NuGet semver. |
| 89 | + INDEX=$(curl -fsS https://api.nuget.org/v3-flatcontainer/terminal.gui/index.json) |
| 90 | + if [ "$CHANNEL" = "stable" ]; then |
| 91 | + TARGET=$(echo "$INDEX" | jq -r '[.versions[] | select(contains("-") | not)] | last') |
| 92 | + else |
| 93 | + TARGET=$(echo "$INDEX" | jq -r '.versions | last') |
| 94 | + fi |
| 95 | + fi |
| 96 | +
|
| 97 | + if [ -z "$TARGET" ] || [ "$TARGET" = "null" ]; then |
| 98 | + echo "::error::Could not resolve a target Terminal.Gui version." |
| 99 | + exit 1 |
| 100 | + fi |
| 101 | +
|
| 102 | + echo "current=$CURRENT" >> "$GITHUB_OUTPUT" |
| 103 | + echo "target=$TARGET" >> "$GITHUB_OUTPUT" |
| 104 | +
|
| 105 | + if [ "$TARGET" = "$CURRENT" ]; then |
| 106 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 107 | + echo "Pin already at ${CURRENT}; nothing to do." |
| 108 | + elif git ls-remote --heads origin "bump/terminal-gui-${TARGET}" | grep -q .; then |
| 109 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 110 | + echo "::warning::bump/terminal-gui-${TARGET} already exists (a previous bump to ${TARGET} failed CI). Skipping." |
| 111 | + else |
| 112 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 113 | + echo "Bumping TerminalGuiVersion: ${CURRENT} → ${TARGET}" |
| 114 | + fi |
| 115 | +
|
| 116 | + - name: Apply pin |
| 117 | + if: steps.resolve.outputs.changed == 'true' |
| 118 | + shell: bash |
| 119 | + run: | |
| 120 | + TARGET="${{ steps.resolve.outputs.target }}" |
| 121 | + sed -i "s|\(<TerminalGuiVersion[^>]*>\)[^<]*\(</TerminalGuiVersion>\)|\1${TARGET}\2|" Directory.Build.props |
| 122 | + grep TerminalGuiVersion Directory.Build.props |
| 123 | +
|
| 124 | + - name: Setup .NET |
| 125 | + if: steps.resolve.outputs.changed == 'true' |
| 126 | + uses: actions/setup-dotnet@v5 |
| 127 | + with: |
| 128 | + dotnet-version: '10.0.x' |
| 129 | + dotnet-quality: 'preview' |
| 130 | + |
| 131 | + - name: Validate (restore, build, test) |
| 132 | + if: steps.resolve.outputs.changed == 'true' |
| 133 | + id: validate |
| 134 | + continue-on-error: true |
| 135 | + shell: bash |
| 136 | + run: | |
| 137 | + set -euo pipefail |
| 138 | + dotnet restore Terminal.Gui.Editor.slnx |
| 139 | + dotnet build Terminal.Gui.Editor.slnx --no-restore -c Release |
| 140 | + dotnet run --project tests/Terminal.Gui.Editor.Tests --no-build -c Release |
| 141 | + dotnet run --project tests/Terminal.Gui.Editor.IntegrationTests --no-build -c Release |
| 142 | + dotnet run --project tests/Terminal.Gui.Editor.ConfigTests --no-build -c Release |
| 143 | +
|
| 144 | + - name: Commit to develop (green) |
| 145 | + if: steps.resolve.outputs.changed == 'true' && steps.validate.outcome == 'success' |
| 146 | + shell: bash |
| 147 | + run: | |
| 148 | + TARGET="${{ steps.resolve.outputs.target }}" |
| 149 | + git add Directory.Build.props |
| 150 | + git commit -m "Bump TerminalGuiVersion to ${TARGET}" |
| 151 | + # develop may have moved while tests ran; replay the bump on top. |
| 152 | + git pull --rebase origin develop |
| 153 | + git push origin develop |
| 154 | + echo "## Bumped TerminalGuiVersion" >> "$GITHUB_STEP_SUMMARY" |
| 155 | + echo "- ${{ steps.resolve.outputs.current }} → ${TARGET} (pushed to develop)" >> "$GITHUB_STEP_SUMMARY" |
| 156 | +
|
| 157 | + - name: Open PR (red) |
| 158 | + if: steps.resolve.outputs.changed == 'true' && steps.validate.outcome != 'success' |
| 159 | + shell: bash |
| 160 | + run: | |
| 161 | + TARGET="${{ steps.resolve.outputs.target }}" |
| 162 | + CURRENT="${{ steps.resolve.outputs.current }}" |
| 163 | + BRANCH="bump/terminal-gui-${TARGET}" |
| 164 | +
|
| 165 | + git checkout -b "$BRANCH" |
| 166 | + git add Directory.Build.props |
| 167 | + git commit -m "Bump TerminalGuiVersion to ${TARGET}" |
| 168 | + git push origin "$BRANCH" |
| 169 | +
|
| 170 | + cat > /tmp/pr_body.md << EOF |
| 171 | + Automated bump of \`TerminalGuiVersion\` from \`${CURRENT}\` to \`${TARGET}\` **failed validation** (build or tests). |
| 172 | +
|
| 173 | + Editor needs source changes to absorb this Terminal.Gui update. See the |
| 174 | + [failed workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}). |
| 175 | + EOF |
| 176 | +
|
| 177 | + gh pr create \ |
| 178 | + --base develop \ |
| 179 | + --head "$BRANCH" \ |
| 180 | + --title "Bump TerminalGuiVersion to ${TARGET} (needs fixes)" \ |
| 181 | + --body-file /tmp/pr_body.md |
| 182 | +
|
| 183 | + echo "::error::TG ${TARGET} broke the build/tests; opened PR from ${BRANCH}." |
| 184 | + exit 1 |
0 commit comments