|
| 1 | +name: release |
| 2 | + |
| 3 | +# Triggered only by a "Bumped versions" commit on develop |
| 4 | +# (Mark Sibly's historical convention). The commit contains ONLY the |
| 5 | +# version constant changes in wx.wx (WAKE_VERSION), |
| 6 | +# wide.wx (WIDE_VERSION) and createrelease.wx (WONKEY_VERSION / WAKE_VERSION / |
| 7 | +# RELEASE_SUFFIX). The workflow reads these versions, rebuilds each platform, |
| 8 | +# recommits the bootstrap binaries, tags and publishes the release. |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: [ develop ] |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + force: |
| 15 | + description: "Force the release without a 'Bumped versions' commit" |
| 16 | + type: boolean |
| 17 | + default: false |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + |
| 22 | +jobs: |
| 23 | + # --------------------------------------------------------------------------- |
| 24 | + # 1. Guard: only proceed on a bump commit, and extract the tag. |
| 25 | + # --------------------------------------------------------------------------- |
| 26 | + guard: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + if: >- |
| 29 | + github.event_name == 'workflow_dispatch' || |
| 30 | + startsWith(github.event.head_commit.message, 'Bumped versions') |
| 31 | + outputs: |
| 32 | + tag: ${{ steps.versions.outputs.tag }} |
| 33 | + wonkey: ${{ steps.versions.outputs.wonkey }} |
| 34 | + wake: ${{ steps.versions.outputs.wake }} |
| 35 | + wide: ${{ steps.versions.outputs.wide }} |
| 36 | + suffix: ${{ steps.versions.outputs.suffix }} |
| 37 | + steps: |
| 38 | + - name: checkout repository |
| 39 | + uses: actions/checkout@v4 |
| 40 | + |
| 41 | + - name: parse versions from createrelease.wx |
| 42 | + id: versions |
| 43 | + run: | |
| 44 | + # Tolerates spacing variations: `:="x"` (createrelease.wx) and `:= "x"` (wx.wx). |
| 45 | + get() { grep -oE "Const $2 *:?= *\"[^\"]*\"" "$1" | head -n1 | sed -E 's/.*"([^"]*)".*/\1/'; } |
| 46 | + cr=src/createrelease/createrelease.wx |
| 47 | + wonkey=$(get "$cr" WONKEY_VERSION) |
| 48 | + wake=$(get "$cr" WAKE_VERSION) |
| 49 | + suffix=$(get "$cr" RELEASE_SUFFIX) |
| 50 | +
|
| 51 | + # WAKE_VERSION must be identical in wx.wx and createrelease.wx (otherwise desynced). |
| 52 | + wake_wx=$(get src/wake/wx.wx WAKE_VERSION) |
| 53 | + if [ "$wake" != "$wake_wx" ]; then |
| 54 | + echo "::error::WAKE_VERSION desynced — createrelease.wx='$wake' vs wx.wx='$wake_wx'" |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | +
|
| 58 | + # WIDE_VERSION lives in wide.wx (used for Wide's title + release notes). |
| 59 | + wide=$(get src/wide/wide.wx WIDE_VERSION) |
| 60 | +
|
| 61 | + echo "wonkey=$wonkey" >> "$GITHUB_OUTPUT" |
| 62 | + echo "wake=$wake" >> "$GITHUB_OUTPUT" |
| 63 | + echo "wide=$wide" >> "$GITHUB_OUTPUT" |
| 64 | + echo "suffix=$suffix" >> "$GITHUB_OUTPUT" |
| 65 | + echo "tag=v${wonkey}${suffix}" >> "$GITHUB_OUTPUT" |
| 66 | + echo "Wonkey=$wonkey Wake=$wake Wide=$wide Suffix='$suffix' Tag=v${wonkey}${suffix}" |
| 67 | +
|
| 68 | + # --------------------------------------------------------------------------- |
| 69 | + # 2. Matrix build: full bootstrap + package generation per platform. |
| 70 | + # --------------------------------------------------------------------------- |
| 71 | + build: |
| 72 | + needs: guard |
| 73 | + strategy: |
| 74 | + fail-fast: false |
| 75 | + matrix: |
| 76 | + include: |
| 77 | + # id = unique artifact key ; host = platform folder (bin/, releases/). |
| 78 | + - id: linux |
| 79 | + host: linux |
| 80 | + runner: ubuntu-latest |
| 81 | + shell: bash |
| 82 | + commit_bins: true |
| 83 | + - id: macos |
| 84 | + host: macos |
| 85 | + runner: macos-latest |
| 86 | + shell: bash |
| 87 | + commit_bins: true |
| 88 | + - id: windows |
| 89 | + host: windows |
| 90 | + runner: windows-2022 |
| 91 | + shell: cmd |
| 92 | + commit_bins: true |
| 93 | + # MSVC variant: same host=windows, but msvc toolchain and NO |
| 94 | + # commit-back of binaries (mingw stays canonical). Additionally produces |
| 95 | + # a wonkey_..._windows-msvc_x64 package. |
| 96 | + - id: windows-msvc |
| 97 | + host: windows |
| 98 | + runner: windows-2022 |
| 99 | + shell: cmd |
| 100 | + msvc: true |
| 101 | + commit_bins: false |
| 102 | + runs-on: ${{ matrix.runner }} |
| 103 | + steps: |
| 104 | + - name: checkout repository |
| 105 | + uses: actions/checkout@v4 |
| 106 | + |
| 107 | + - name: install linux packages |
| 108 | + if: matrix.host == 'linux' |
| 109 | + run: | |
| 110 | + sudo apt-get update -y |
| 111 | + sudo apt-get install -y g++-multilib libopenal-dev libpulse-dev libsdl2-dev |
| 112 | +
|
| 113 | + # --- Windows: toolchain selection --------------------------------------- |
| 114 | + # MSVC: WX_USE_MSVC left empty => wake calls FindMSVC() which locates |
| 115 | + # Visual Studio + Windows Kits on its own (WX_MSVC_VERSIONS = years to scan). |
| 116 | + # gcc : WX_USE_MSVC=0 explicitly forces mingw (otherwise autodetection |
| 117 | + # would switch to msvc since VS is present on the runner). |
| 118 | + - name: configure windows toolchain |
| 119 | + if: matrix.host == 'windows' |
| 120 | + shell: pwsh |
| 121 | + env: |
| 122 | + MATRIX_MSVC: ${{ matrix.msvc }} |
| 123 | + run: | |
| 124 | + if ($env:MATRIX_MSVC -eq 'true') { |
| 125 | + "WX_MSVC_VERSIONS=2022" | Out-File $env:GITHUB_ENV -Append -Encoding utf8 |
| 126 | + } else { |
| 127 | + "WX_USE_MSVC=0" | Out-File $env:GITHUB_ENV -Append -Encoding utf8 |
| 128 | + } |
| 129 | +
|
| 130 | + # --- Bootstrap (same sequence as the per-platform workflows) ------------ |
| 131 | + - name: bootstrap (unix) |
| 132 | + if: matrix.host != 'windows' |
| 133 | + run: | |
| 134 | + cd scripts |
| 135 | + ./rebuildmods.sh |
| 136 | + ./rebuildwake.sh |
| 137 | + ./rebuildwide.sh |
| 138 | + ./rebuildlauncher.sh |
| 139 | + ./makedocs.sh |
| 140 | +
|
| 141 | + - name: bootstrap (windows) |
| 142 | + if: matrix.host == 'windows' |
| 143 | + shell: cmd |
| 144 | + run: | |
| 145 | + cd %CD%\scripts |
| 146 | + rebuildmods.bat && rebuildwake.bat && rebuildwide.bat && rebuildlauncher.bat && makedocs.bat |
| 147 | +
|
| 148 | + # --- createrelease: no dedicated script, build via `wake app` ----------- |
| 149 | + - name: build createrelease (unix) |
| 150 | + if: matrix.host != 'windows' |
| 151 | + run: | |
| 152 | + bin/${{ matrix.host }}/wake app -clean -apptype=console -config=release \ |
| 153 | + -product=src/createrelease/createrelease.products/${{ matrix.host }}/createrelease \ |
| 154 | + src/createrelease/createrelease.wx |
| 155 | +
|
| 156 | + - name: build createrelease (windows) |
| 157 | + if: matrix.host == 'windows' |
| 158 | + shell: cmd |
| 159 | + run: | |
| 160 | + bin\windows\wake app -clean -apptype=console -config=release -product=src/createrelease/createrelease.products/windows/createrelease src/createrelease/createrelease.wx |
| 161 | +
|
| 162 | + # --- Package generation (createrelease writes into releases/<host>/) ---- |
| 163 | + - name: run createrelease (unix) |
| 164 | + if: matrix.host != 'windows' |
| 165 | + run: src/createrelease/createrelease.products/${{ matrix.host }}/createrelease |
| 166 | + |
| 167 | + - name: run createrelease (windows) |
| 168 | + if: matrix.host == 'windows' |
| 169 | + shell: cmd |
| 170 | + run: src\createrelease\createrelease.products\windows\createrelease.exe |
| 171 | + |
| 172 | + # --- Windows: compile the Inno installer from the generated .iss -------- |
| 173 | + - name: build inno installer (windows) |
| 174 | + if: matrix.host == 'windows' |
| 175 | + shell: cmd |
| 176 | + run: | |
| 177 | + for %%f in (releases\windows\*.iss) do iscc "%%f" |
| 178 | +
|
| 179 | + # --- Artifacts: bootstrap binaries (canonical) + packages -------------- |
| 180 | + # Only canonical variants (commit_bins) upload their binaries: |
| 181 | + # the msvc variant must not overwrite the committed mingw. |
| 182 | + - name: upload bootstrap binaries |
| 183 | + if: matrix.commit_bins |
| 184 | + uses: actions/upload-artifact@v4 |
| 185 | + with: |
| 186 | + name: bin-${{ matrix.host }} |
| 187 | + path: bin/${{ matrix.host }}/ |
| 188 | + retention-days: 1 |
| 189 | + |
| 190 | + - name: upload release packages |
| 191 | + uses: actions/upload-artifact@v4 |
| 192 | + with: |
| 193 | + name: pkg-${{ matrix.id }} |
| 194 | + path: releases/${{ matrix.host }}/ |
| 195 | + retention-days: 7 |
| 196 | + |
| 197 | + # --------------------------------------------------------------------------- |
| 198 | + # 3. Recommit the bootstrap binaries (required: clones rebuild on top of them) |
| 199 | + # + tag. [skip ci] prevents the workflow from re-triggering. |
| 200 | + # --------------------------------------------------------------------------- |
| 201 | + commit-binaries: |
| 202 | + needs: [guard, build] |
| 203 | + runs-on: ubuntu-latest |
| 204 | + steps: |
| 205 | + - name: checkout repository |
| 206 | + uses: actions/checkout@v4 |
| 207 | + with: |
| 208 | + ref: develop |
| 209 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 210 | + |
| 211 | + - name: download all bootstrap binaries |
| 212 | + uses: actions/download-artifact@v4 |
| 213 | + with: |
| 214 | + pattern: bin-* |
| 215 | + path: .artifacts |
| 216 | + |
| 217 | + - name: place binaries |
| 218 | + run: | |
| 219 | + for host in linux macos windows; do |
| 220 | + if [ -d ".artifacts/bin-$host" ]; then |
| 221 | + mkdir -p "bin/$host" |
| 222 | + cp -R ".artifacts/bin-$host/." "bin/$host/" |
| 223 | + fi |
| 224 | + done |
| 225 | + rm -rf .artifacts |
| 226 | +
|
| 227 | + - name: commit, tag & push |
| 228 | + run: | |
| 229 | + git config user.name "wonkey-ci" |
| 230 | + git config user.email "ci@wonkey-coders.invalid" |
| 231 | + git add bin/ |
| 232 | + if git diff --cached --quiet; then |
| 233 | + echo "No binaries changed." |
| 234 | + else |
| 235 | + git commit -m "chore: bootstrap binaries ${{ needs.guard.outputs.tag }} [skip ci]" |
| 236 | + git push origin develop |
| 237 | + fi |
| 238 | + git tag -f "${{ needs.guard.outputs.tag }}" |
| 239 | + git push -f origin "${{ needs.guard.outputs.tag }}" |
| 240 | +
|
| 241 | + # --------------------------------------------------------------------------- |
| 242 | + # 4. GitHub release with all installation packages. |
| 243 | + # --------------------------------------------------------------------------- |
| 244 | + release: |
| 245 | + needs: [guard, commit-binaries] |
| 246 | + runs-on: ubuntu-latest |
| 247 | + steps: |
| 248 | + - name: download all packages |
| 249 | + uses: actions/download-artifact@v4 |
| 250 | + with: |
| 251 | + pattern: pkg-* |
| 252 | + path: dist |
| 253 | + merge-multiple: true |
| 254 | + |
| 255 | + - name: create github release |
| 256 | + uses: softprops/action-gh-release@v2 |
| 257 | + with: |
| 258 | + tag_name: ${{ needs.guard.outputs.tag }} |
| 259 | + name: Wonkey ${{ needs.guard.outputs.wonkey }}${{ needs.guard.outputs.suffix }} |
| 260 | + body: | |
| 261 | + Wonkey ${{ needs.guard.outputs.wonkey }}${{ needs.guard.outputs.suffix }} |
| 262 | + wake ${{ needs.guard.outputs.wake }} |
| 263 | + wide ${{ needs.guard.outputs.wide }} |
| 264 | + files: dist/**/* |
| 265 | + fail_on_unmatched_files: false |
0 commit comments