pinready 0.27.9

Cross-platform configurator and launcher supporting the adoption of Visual Pinball 10.8.1 — for testers and early adopters, not a replacement for a stable production setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
name: CI

on:
  push:
    tags: ['v*']
  pull_request:
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always
  LZMA_API_STATIC: 1

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-24.04
            target: x86_64-unknown-linux-gnu
            label: linux-x86_64
            lint: true
          - os: ubuntu-24.04
            target: aarch64-unknown-linux-gnu
            label: linux-aarch64
            cross: true
          - os: macos-latest
            target: aarch64-apple-darwin
            label: macos-aarch64
          - os: macos-latest
            target: x86_64-apple-darwin
            label: macos-x86_64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            label: windows-x86_64

    runs-on: ${{ matrix.os }}
    name: ${{ matrix.label }}

    steps:
      - uses: actions/checkout@v7

      - name: Install Rust
        # Épinglé au SHA du commit (voir le commentaire dans le job release) —
        # `stable` est une branche mobile, un SHA ne l'est pas.
        uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4  # stable
        with:
          toolchain: stable
          targets: ${{ matrix.target }}
          components: ${{ matrix.lint && 'rustfmt, clippy' || '' }}

      # Garde-fou tag ↔ Cargo.toml. Un tag `vX.Y.Z` doit correspondre à la
      # version du crate : deux releases voisines sont déjà parties avec un
      # Cargo.toml en retard d'une version, run au vert et personne pour le
      # voir. On échoue ici, dans le premier job du tag, donc avant toute
      # signature et avant la publication de la release. Le suffixe de
      # pré-release est retiré : `v1.2.3-rc1` vaut Cargo.toml `1.2.3`.
      - name: Check tag matches Cargo.toml version
        if: startsWith(github.ref, 'refs/tags/v')
        shell: bash
        run: |
          set -euo pipefail
          tag="${GITHUB_REF_NAME#v}"
          tag="${tag%%-*}"
          py=$(command -v python3 || command -v python)
          crate=$(cargo metadata --no-deps --format-version 1 \
            | "$py" -c 'import json,sys; pkgs=json.load(sys.stdin)["packages"]; print(next(p["version"] for p in pkgs if p["name"]=="pinready"))')
          if [ "$tag" != "$crate" ]; then
            echo "::error::Tag $GITHUB_REF_NAME (version $tag) != version Cargo.toml ($crate) — aligne Cargo.toml ou retague."
            exit 1
          fi
          echo "Tag $GITHUB_REF_NAME <-> Cargo.toml $crate : OK"

      - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0  # v2.9.3
        with:
          key: ${{ matrix.os }}-${{ matrix.target }}

      - name: Install dependencies (Linux native)
        if: runner.os == 'Linux' && !matrix.cross
        run: |
          sudo apt-get update
          sudo apt-get install -y build-essential cmake pkg-config \
            libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev \
            libxkbcommon-dev libssl-dev \
            libasound2-dev libpulse-dev \
            libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev \
            libxtst-dev libxss-dev libwayland-dev wayland-protocols \
            libdbus-1-dev libdrm-dev libgbm-dev \
            libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev \
            libudev-dev

      # Cross-compile aarch64 from x86_64 (hosted ubuntu-*-arm runners are
      # too unstable to rely on for releases). cross-rs runs the build
      # inside a Docker container that has the aarch64 toolchain + the
      # multiarch deps installed via Cross.toml's pre-build hook.
      - name: Install cross
        if: matrix.cross
        run: cargo install cross --locked --version 0.2.5

      # --- Lint (linux-x86_64 only) ---
      - name: Check formatting
        if: matrix.lint
        run: cargo fmt --check

      - name: Clippy
        if: matrix.lint
        run: cargo clippy --release --all-targets --all-features --target ${{ matrix.target }} -- -D warnings

      # --- Build ---
      - name: Set macOS deployment target
        if: runner.os == 'macOS'
        run: |
          echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV
          echo "CFLAGS=-mmacosx-version-min=11.0" >> $GITHUB_ENV
          echo "CXXFLAGS=-mmacosx-version-min=11.0" >> $GITHUB_ENV
          CLANG_RT_DIR=$(clang --print-search-dirs | grep libraries | sed 's/libraries: =//;s/:.*//')
          CLANG_RT_LIB=$(find "$CLANG_RT_DIR" -name 'libclang_rt.osx.a' 2>/dev/null | head -1)
          if [ -n "$CLANG_RT_LIB" ]; then
            echo "RUSTFLAGS=-C link-arg=$CLANG_RT_LIB" >> $GITHUB_ENV
            echo "Found clang_rt: $CLANG_RT_LIB"
          else
            echo "Warning: libclang_rt.osx.a not found"
          fi

      - name: Build (native)
        if: '!matrix.cross'
        run: cargo build --release --target ${{ matrix.target }} ${{ runner.os == 'Windows' && '--features win-icon' || '' }}

      - name: Build (cross)
        if: matrix.cross
        run: cross build --release --target ${{ matrix.target }}

      # Tests are skipped for cross-compiled targets (no aarch64 binary
      # can run on the x86_64 host) and for the macOS x86_64 cross-build
      # (Apple silicon runner can't execute x86_64 release binaries).
      - name: Run tests
        if: matrix.target != 'x86_64-apple-darwin' && !matrix.cross
        run: cargo test --release --target ${{ matrix.target }}

      # --- Empaquetage (binaires non signés ; la signature Apple est faite plus
      # bas, dans un job dédié derrière l'environnement `signing`). ---
      - name: Package (Unix)
        if: runner.os != 'Windows'
        run: tar czf pinready-${{ matrix.label }}.tar.gz -C target/${{ matrix.target }}/release pinready

      - name: Package (Windows)
        if: runner.os == 'Windows'
        run: Compress-Archive -Path target/${{ matrix.target }}/release/pinready.exe -DestinationPath pinready-${{ matrix.label }}.zip

      - name: Upload artifact
        uses: actions/upload-artifact@v7
        with:
          name: pinready-${{ matrix.label }}
          path: pinready-${{ matrix.label }}.*

  # Signature + notarisation Apple. Derrière `signing` au même titre que Windows :
  # les secrets Apple vivent désormais dans cet environnement, et seul un job qui
  # le déclare peut les lire. Une signature Developer ID engage l'identité (et
  # donc la réputation) du propriétaire, elle ne doit jamais partir sans
  # approbation explicite.
  sign-apple:
    needs: build
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: macos-latest
    environment: signing
    steps:
      - name: Download the macOS artifacts
        uses: actions/download-artifact@v8
        with:
          pattern: pinready-macos-*
          path: dl

      - name: Import Apple Developer ID certificate
        env:
          APPLE_CERTIFICATE_P12: ${{ secrets.APPLE_CERTIFICATE_P12 }}
          APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
        run: |
          KEYCHAIN_PASSWORD=$(openssl rand -base64 32)
          KEYCHAIN_PATH=$RUNNER_TEMP/signing.keychain-db
          security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
          security set-keychain-settings -lut 21600 "$KEYCHAIN_PATH"
          security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
          echo "$APPLE_CERTIFICATE_P12" | base64 --decode > $RUNNER_TEMP/certificate.p12
          security import $RUNNER_TEMP/certificate.p12 \
            -k "$KEYCHAIN_PATH" \
            -P "$APPLE_CERTIFICATE_PASSWORD" \
            -T /usr/bin/codesign
          security list-keychain -d user -s "$KEYCHAIN_PATH"
          security set-key-partition-list \
            -S apple-tool:,apple: \
            -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"

      - name: Sign & notarize the macOS binaries
        env:
          APPLE_ID: ${{ secrets.APPLE_ID }}
          APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
          APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
        run: |
          # Submit and poll with timeout + retry (3 attempts, 5/15/45 min backoff)
          notarize_once() {
            local zip="$1" label="$2" timeout="$3"

            local output
            output=$(xcrun notarytool submit "$zip" \
              --apple-id "$APPLE_ID" \
              --password "$APPLE_ID_PASSWORD" \
              --team-id "$APPLE_TEAM_ID" \
              --verbose 2>&1)
            echo "$output"
            local sub_id
            sub_id=$(echo "$output" | awk '/id:/{print $2; exit}')
            # The submit POST itself can time out on Apple's side (seen in
            # v0.14.0 CI). Treat "no submission ID" as retryable (rc=2) so
            # the backoff/retry loop above catches transient outages
            # instead of forcing a manual full-workflow re-run.
            [ -n "$sub_id" ] || { echo "$label: failed to get submission ID (transient, will retry)"; return 2; }
            echo "$label: submitted (id: $sub_id)"

            local deadline=$((SECONDS + timeout))
            while [ $SECONDS -lt $deadline ]; do
              sleep 30
              local info
              info=$(xcrun notarytool info "$sub_id" \
                --apple-id "$APPLE_ID" \
                --password "$APPLE_ID_PASSWORD" \
                --team-id "$APPLE_TEAM_ID" 2>&1) || { echo "$label: network error, retrying poll..."; continue; }

              local status
              status=$(echo "$info" | awk '/status:/{print $2; exit}')
              echo "$label: $status"

              case "$status" in
                Accepted) return 0 ;;
                Invalid|Rejected)
                  xcrun notarytool log "$sub_id" \
                    --apple-id "$APPLE_ID" \
                    --password "$APPLE_ID_PASSWORD" \
                    --team-id "$APPLE_TEAM_ID" 2>&1 || true
                  return 1 ;;
              esac
            done
            echo "$label: timed out after $((timeout / 60)) minutes"
            return 2  # timeout, retryable
          }

          notarize() {
            local zip="$1" label="$2"
            local backoffs=(300 900 2700)  # 5 / 15 / 45 minutes
            for i in 0 1 2; do
              echo "$label: attempt $((i + 1))/3"
              notarize_once "$zip" "$label" "${backoffs[$i]}" && return 0
              local rc=$?
              [ $rc -eq 2 ] || return $rc  # only retry on timeout (rc=2)
              [ $i -lt 2 ] && echo "$label: retrying after timeout..."
            done
            return 1
          }

          for label in macos-aarch64 macos-x86_64; do
            echo "::group::$label"
            work="$RUNNER_TEMP/$label"
            mkdir -p "$work"
            tar xzf "dl/pinready-$label/pinready-$label.tar.gz" -C "$work"

            codesign --force --options runtime \
              --sign "Developer ID Application: Sylvain Gargasson ($APPLE_TEAM_ID)" \
              --timestamp "$work/pinready"
            codesign --verify --strict --verbose=2 "$work/pinready"

            ditto -c -k --keepParent "$work/pinready" "$RUNNER_TEMP/$label.zip"
            notarize "$RUNNER_TEMP/$label.zip" "$label" || exit 1

            tar czf "pinready-$label.tar.gz" -C "$work" pinready
            echo "::endgroup::"
          done

      - name: Re-upload the signed macOS aarch64 artifact
        uses: actions/upload-artifact@v7
        with:
          name: pinready-macos-aarch64
          path: pinready-macos-aarch64.tar.gz
          overwrite: true

      - name: Re-upload the signed macOS x86_64 artifact
        uses: actions/upload-artifact@v7
        with:
          name: pinready-macos-x86_64
          path: pinready-macos-x86_64.tar.gz
          overwrite: true

  # Authenticode-sign the Windows binary with ssign (the Linux runner signs the
  # .exe — no Windows, no vendor stack). Gated by the `signing` environment
  # (owner approval); the release below waits for it, so a tag becomes
  # build → approve → signed release.
  sign-windows:
    needs: build
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-latest
    environment: signing
    steps:
      - name: Install ssign (prebuilt binary from the latest release)
        run: |
          curl -fsSL https://github.com/Le-Syl21/ssign/releases/latest/download/ssign-linux-x86_64.tar.gz | tar xz
          sudo install -m755 ssign /usr/local/bin/ssign

      - name: Download the Windows artifact
        uses: actions/download-artifact@v8
        with:
          name: pinready-windows-x86_64
          path: dl

      - name: Sign pinready.exe with ssign (via Certum)
        env:
          CERTUM_EMAIL: ${{ secrets.CERTUM_EMAIL }}
          CERTUM_OTP: ${{ secrets.CERTUM_OTP }}
        run: |
          unzip -o dl/pinready-windows-x86_64.zip -d dl
          ssign --verbose \
            -n "PinReady" -u "https://github.com/${{ github.repository }}" \
            dl/pinready.exe
          sudo apt-get update -qq && sudo apt-get install -y osslsigncode
          # Vérifie les faits, pas la présence d'une phrase. « Calculated message
          # digest » apparaît AUSSI quand le digest ne correspond pas, et ne dit
          # rien de l'horodatage : ce contrôle laissait donc passer une signature
          # que Windows aurait rejetée, et des binaires non horodatés — donc
          # invalides dès l'expiration du certificat.
          verify_signature() {
            local out
            out=$(osslsigncode verify "$1" 2>&1) || true
            echo "$out"
            if echo "$out" | grep -q "MISMATCH"; then
              echo "::error::$1 : digest Authenticode invalide (Windows le verrait comme falsifié)"
              return 1
            fi
            if echo "$out" | grep -q "Timestamp is not available"; then
              echo "::error::$1 : signature non horodatée (invalide dès l'expiration du certificat)"
              return 1
            fi
            if ! echo "$out" | grep -q "Signature verification: ok"; then
              echo "::error::$1 : vérification de signature échouée"
              return 1
            fi
          }
          verify_signature dl/pinready.exe
          (cd dl && rm -f pinready-windows-x86_64.zip && zip -j pinready-windows-x86_64.zip pinready.exe)

      - name: Re-upload the signed Windows artifact
        uses: actions/upload-artifact@v7
        with:
          name: pinready-windows-x86_64
          path: dl/pinready-windows-x86_64.zip
          overwrite: true

  release:
    needs: [build, sign-windows, sign-apple]
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-24.04
    permissions:
      contents: write

    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v8
        with:
          path: artifacts

      - name: Create release
        # Action tierce épinglée au SHA du commit, pas au tag : en mars 2026,
        # 76 des 77 tags de version d'`aquasecurity/trivy-action` ont été
        # force-pushés vers du code malveillant. Un tag est mutable, un SHA non.
        # Le commentaire garde la version lisible pour les mises à jour.
        uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64  # v3
        with:
          generate_release_notes: true
          files: artifacts/**/*

  publish-crate:
    # `cargo install pinready`. Last, once the GitHub release exists: a
    # crates.io publish cannot be undone (only yanked), so a failed release
    # must not have burnt the version number. Not for pre-releases.
    needs: [release]
    if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref_name, '-')
    runs-on: ubuntu-24.04
    environment: crates-io
    permissions:
      contents: read
      id-token: write  # the OIDC token crates.io's Trusted Publishing checks
    steps:
      - uses: actions/checkout@v7
      - uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4  # stable
      - name: Build dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y build-essential cmake pkg-config \
            libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev \
            libxkbcommon-dev libssl-dev libasound2-dev libpulse-dev \
            libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev \
            libxtst-dev libxss-dev libwayland-dev wayland-protocols \
            libdbus-1-dev libdrm-dev libgbm-dev \
            libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libudev-dev
      # Trusted Publishing: no long-lived secret. GitHub vouches for this
      # workflow (repo, file, environment) and crates.io, which has it on
      # record for the crate, hands out a token that expires with the job.
      - name: Get a temporary crates.io token
        id: auth
        uses: rust-lang/crates-io-auth-action@3268eb413133e2960fa4ae0e963ca76380c54cd9  # v1.0.6
      - name: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
        run: cargo publish