alef 0.26.0

Opinionated polyglot binding generator for Rust libraries
Documentation
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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
name: Publish

on:
  release:
    types: [published]
  workflow_dispatch:
    inputs:
      tag:
        description: "Git tag to publish (e.g. v0.4.6)"
        required: true
        type: string
      dry_run:
        description: "Dry run — build everything but skip registry publishes"
        required: false
        default: false
        type: boolean
      force_republish:
        description: "Force publish even if version already exists"
        required: false
        default: false
        type: boolean
      targets:
        description: "Comma-separated targets (empty = all). Values: crates,cli,homebrew"
        required: false
        default: ""
        type: string
  repository_dispatch:
    types: [publish-release]

concurrency:
  group: publish-${{ github.event.inputs.tag || github.ref_name || github.run_id }}
  cancel-in-progress: false

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always

jobs:
  prepare:
    name: Prepare release
    runs-on: runner-medium
    outputs:
      tag: ${{ steps.meta.outputs.tag }}
      version: ${{ steps.meta.outputs.version }}
      checkout_ref: ${{ steps.meta.outputs.checkout_ref }}
      dry_run: ${{ steps.meta.outputs.dry_run }}
      force_republish: ${{ steps.meta.outputs.force_republish }}
      release_crates: ${{ steps.meta.outputs.release_crates }}
      release_cli: ${{ steps.meta.outputs.release_cli }}
      release_homebrew: ${{ steps.meta.outputs.release_homebrew }}
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 0

      - name: Prepare release metadata
        id: meta
        uses: kreuzberg-dev/actions/prepare-release-metadata@v1
        with:
          available-targets: crates,cli,homebrew
          # Bootstrap alef from main (build from source) so this step doesn't
          # try to download a binary from the just-created release tag — those
          # binaries don't exist yet (they're built later in this same run).
          alef-version: main

  validate-versions:
    name: Validate versions
    needs: prepare
    runs-on: runner-medium
    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ needs.prepare.outputs.checkout_ref }}

      - name: Validate manifest versions
        uses: kreuzberg-dev/actions/validate-versions@v1
        with:
          version: ${{ needs.prepare.outputs.version }}
          alef-version: main

  check-cratesio:
    name: Check crates.io
    needs: prepare
    if: needs.prepare.outputs.release_crates == 'true'
    runs-on: runner-medium
    outputs:
      exists: ${{ steps.check.outputs.exists }}
    steps:
      - name: Check crates.io for alef
        id: check
        uses: kreuzberg-dev/actions/check-registry@v1
        with:
          registry: cratesio
          package: alef
          version: ${{ needs.prepare.outputs.version }}
          alef-version: main

  check-github-release:
    name: Check GitHub release
    needs: prepare
    if: needs.prepare.outputs.release_cli == 'true'
    runs-on: runner-medium
    outputs:
      exists: ${{ steps.check.outputs.exists }}
    steps:
      - name: Check GitHub release assets
        id: check
        uses: kreuzberg-dev/actions/check-registry@v1
        with:
          registry: github-release
          package: alef
          version: ${{ needs.prepare.outputs.version }}
          tag: ${{ needs.prepare.outputs.tag }}
          asset-prefix: alef-
          repo: kreuzberg-dev/alef
          alef-version: main

  check-homebrew:
    name: Check Homebrew tap
    needs: prepare
    if: needs.prepare.outputs.release_homebrew == 'true'
    runs-on: runner-medium
    outputs:
      exists: ${{ steps.check.outputs.exists }}
    steps:
      - name: Check Homebrew formula
        id: check
        uses: kreuzberg-dev/actions/check-registry@v1
        with:
          registry: homebrew
          package: alef
          version: ${{ needs.prepare.outputs.version }}
          tap-repo: kreuzberg-dev/homebrew-tap
          alef-version: main

  build-cli:
    name: Build CLI (${{ matrix.label }})
    needs: [prepare, validate-versions, check-github-release]
    if: |
      always() &&
      needs.prepare.outputs.release_cli == 'true' &&
      needs.validate-versions.result == 'success' &&
      (needs.check-github-release.outputs.exists != 'true' || needs.prepare.outputs.force_republish == 'true')
    strategy:
      fail-fast: false
      matrix:
        include:
          - label: linux-x86_64
            runner: runner-medium
            target: x86_64-unknown-linux-gnu
          - label: linux-aarch64
            runner: runner-medium-arm64
            target: aarch64-unknown-linux-gnu
          - label: macos-arm64
            runner: macos-latest
            target: aarch64-apple-darwin
    runs-on: ${{ matrix.runner }}
    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ needs.prepare.outputs.checkout_ref }}

      - name: Setup Rust
        uses: kreuzberg-dev/actions/setup-rust@v1
        with:
          target: ${{ matrix.target }}
          cache-key-prefix: publish-cli-${{ matrix.label }}
          install-llvm-cov: "false"
          macos-dynamic-lookup: "false"
          disable-cache: ${{ runner.os == 'Windows' && 'true' || 'false' }}

      - name: Build CLI
        id: build
        uses: kreuzberg-dev/actions/build-rust-cli@v1
        with:
          package-name: alef
          binary-name: alef
          target: ${{ matrix.target }}

      - name: Create release archive
        id: archive
        shell: bash
        run: |
          set -euo pipefail
          ARCHIVE_DIR="alef-${{ matrix.target }}"
          mkdir -p "${ARCHIVE_DIR}"
          cp "${{ steps.build.outputs.binary-path }}" "${ARCHIVE_DIR}/"
          if [[ "${{ runner.os }}" == "Windows" ]]; then
            ARCHIVE_NAME="alef-${{ matrix.target }}.zip"
            7z a "${ARCHIVE_NAME}" "${ARCHIVE_DIR}"
          else
            ARCHIVE_NAME="alef-${{ matrix.target }}.tar.gz"
            tar -czf "${ARCHIVE_NAME}" "${ARCHIVE_DIR}"
          fi
          echo "path=${ARCHIVE_NAME}" >> "$GITHUB_OUTPUT"
          echo "name=${ARCHIVE_NAME}" >> "$GITHUB_OUTPUT"

      - name: Upload CLI artifact
        uses: actions/upload-artifact@v7
        with:
          name: cli-${{ matrix.label }}
          path: ${{ steps.archive.outputs.path }}
          retention-days: 14

  publish-homebrew-formula:
    name: Update Homebrew formula
    needs: [prepare, validate-versions, check-homebrew, publish-crates]
    if: |
      always() &&
      needs.prepare.outputs.release_homebrew == 'true' &&
      needs.prepare.outputs.dry_run != 'true' &&
      needs.validate-versions.result == 'success' &&
      (needs.check-homebrew.outputs.exists != 'true' || needs.prepare.outputs.force_republish == 'true') &&
      needs.publish-crates.result != 'failure'
    runs-on: runner-medium
    steps:
      - uses: actions/create-github-app-token@v3
        id: tap-token
        with:
          app-id: ${{ secrets.BOT_APP_ID }}
          private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
          owner: kreuzberg-dev
          repositories: homebrew-tap

      - uses: actions/checkout@v7
        with:
          ref: ${{ needs.prepare.outputs.checkout_ref }}

      - uses: actions/checkout@v7
        with:
          repository: kreuzberg-dev/homebrew-tap
          token: ${{ steps.tap-token.outputs.token }}
          path: homebrew-tap

      - name: Update formula
        env:
          TAG: ${{ needs.prepare.outputs.tag }}
          VERSION: ${{ needs.prepare.outputs.version }}
          TAP_DIR: ${{ github.workspace }}/homebrew-tap
        run: scripts/publish/update-homebrew-formula.sh

      - name: Commit and push formula
        working-directory: homebrew-tap
        env:
          GH_TOKEN: ${{ steps.tap-token.outputs.token }}
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          if git diff --quiet Formula/alef.rb; then
            echo "No formula changes; skipping commit."
            exit 0
          fi
          git add Formula/alef.rb
          git commit -m "alef ${{ needs.prepare.outputs.version }}"
          git push origin HEAD

  homebrew-bottles:
    name: Build Homebrew bottle (${{ matrix.bottle_tag }})
    needs: [prepare, publish-homebrew-formula]
    if: |
      always() &&
      needs.prepare.outputs.release_homebrew == 'true' &&
      needs.prepare.outputs.dry_run != 'true' &&
      needs.publish-homebrew-formula.result == 'success'
    runs-on: ${{ matrix.os }}
    timeout-minutes: 90
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: macos-latest
            bottle_tag: arm64_sequoia
            install_brew: false
          - os: macos-15-intel
            bottle_tag: sequoia
            install_brew: false
          - os: ubuntu-latest
            bottle_tag: x86_64_linux
            install_brew: true
          - os: ubuntu-24.04-arm
            bottle_tag: arm64_linux
            install_brew: true
    steps:
      - uses: actions/create-github-app-token@v3
        id: app-token
        with:
          app-id: ${{ secrets.BOT_APP_ID }}
          private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
          owner: kreuzberg-dev

      - uses: actions/checkout@v7
        with:
          ref: ${{ needs.prepare.outputs.checkout_ref }}

      - name: Install Homebrew (Linux)
        if: ${{ matrix.install_brew }}
        uses: kreuzberg-dev/actions/install-homebrew-linux@v1

      - name: Build bottles
        uses: kreuzberg-dev/actions/homebrew-build-bottles@v1
        with:
          tag: ${{ needs.prepare.outputs.tag }}
          version: ${{ needs.prepare.outputs.version }}
          tap: kreuzberg-dev/homebrew-tap
          formulas: alef
          out-dir: ${{ github.workspace }}/bottle-json
          github-repo: kreuzberg-dev/alef
          token: ${{ steps.app-token.outputs.token }}

      - name: Upload bottle JSON manifests
        uses: actions/upload-artifact@v7
        with:
          name: homebrew-bottle-json-${{ matrix.bottle_tag }}
          path: ${{ github.workspace }}/bottle-json/*.json
          if-no-files-found: error
          retention-days: 14

  publish-homebrew-bottles:
    name: Merge Homebrew bottle DSL
    needs: [prepare, publish-homebrew-formula, homebrew-bottles]
    if: |
      always() &&
      needs.prepare.outputs.release_homebrew == 'true' &&
      needs.prepare.outputs.dry_run != 'true' &&
      needs.publish-homebrew-formula.result == 'success' &&
      needs.homebrew-bottles.result == 'success'
    runs-on: runner-medium
    steps:
      - uses: actions/create-github-app-token@v3
        id: tap-token
        with:
          app-id: ${{ secrets.BOT_APP_ID }}
          private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
          owner: kreuzberg-dev
          repositories: homebrew-tap

      - uses: actions/checkout@v7
        with:
          ref: ${{ needs.prepare.outputs.checkout_ref }}

      - uses: actions/checkout@v7
        with:
          repository: kreuzberg-dev/homebrew-tap
          token: ${{ steps.tap-token.outputs.token }}
          path: homebrew-tap

      - uses: actions/download-artifact@v8
        with:
          pattern: homebrew-bottle-json-*
          path: ${{ github.workspace }}/bottle-json
          merge-multiple: true

      - name: Merge bottle DSL into formula
        uses: kreuzberg-dev/actions/homebrew-merge-bottles@v1
        with:
          tag: ${{ needs.prepare.outputs.tag }}
          version: ${{ needs.prepare.outputs.version }}
          tap-dir: ${{ github.workspace }}/homebrew-tap
          json-dir: ${{ github.workspace }}/bottle-json
          formulas: alef
          github-repo: kreuzberg-dev/alef

      - name: Commit and push bottle DSL
        working-directory: homebrew-tap
        env:
          GH_TOKEN: ${{ steps.tap-token.outputs.token }}
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          if git diff --quiet Formula/alef.rb; then
            echo "No bottle DSL changes; skipping commit."
            exit 0
          fi
          git add Formula/alef.rb
          git commit -m "alef ${{ needs.prepare.outputs.version }}: add bottle DSL"
          git push origin HEAD

  upload-release-assets:
    name: Upload release assets
    needs: [prepare, validate-versions, check-github-release, build-cli]
    if: |
      always() &&
      needs.prepare.outputs.release_cli == 'true' &&
      needs.validate-versions.result == 'success' &&
      needs.build-cli.result == 'success' &&
      (needs.check-github-release.outputs.exists != 'true' || needs.prepare.outputs.force_republish == 'true')
    runs-on: runner-medium
    steps:
      - uses: actions/create-github-app-token@v3
        id: app-token
        with:
          app-id: ${{ secrets.BOT_APP_ID }}
          private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
          owner: kreuzberg-dev

      - uses: actions/checkout@v7
        with:
          ref: ${{ needs.prepare.outputs.checkout_ref }}

      - name: Download all CLI artifacts
        uses: actions/download-artifact@v8
        with:
          pattern: cli-*
          path: dist/cli
          merge-multiple: true

      - name: Upload CLI artifacts to release
        uses: kreuzberg-dev/actions/publish-github-release@v1
        with:
          tag: ${{ needs.prepare.outputs.tag }}
          title: ${{ needs.prepare.outputs.tag }}
          artifacts: "dist/cli/*"
          generate-notes: "false"
          draft: "false"
          dry-run: ${{ needs.prepare.outputs.dry_run }}
          token: ${{ steps.app-token.outputs.token }}

  publish-crates:
    name: Publish crates.io
    needs: [prepare, validate-versions, check-cratesio]
    if: |
      always() &&
      needs.prepare.outputs.release_crates == 'true' &&
      needs.validate-versions.result == 'success' &&
      (needs.check-cratesio.outputs.exists != 'true' || needs.prepare.outputs.force_republish == 'true')
    runs-on: runner-medium
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ needs.prepare.outputs.checkout_ref }}

      - name: Setup Rust
        uses: kreuzberg-dev/actions/setup-rust@v1
        with:
          install-llvm-cov: "false"

      - name: Publish to crates.io
        uses: kreuzberg-dev/actions/publish-crates@v1
        with:
          crates: alef
          version: ${{ needs.prepare.outputs.version }}
          dry-run: ${{ needs.prepare.outputs.dry_run }}

  finalize:
    name: Finalize release
    needs: [prepare, upload-release-assets, publish-crates, publish-homebrew-bottles]
    if: always()
    runs-on: runner-medium
    steps:
      - uses: actions/checkout@v7
        with:
          ref: ${{ needs.prepare.outputs.checkout_ref }}

      - name: Publish summary
        if: always()
        run: |
          {
            echo "## Release ${{ needs.prepare.outputs.tag }}"
            echo ""
            echo "| Registry | Status |"
            echo "|----------|--------|"
          } >> "$GITHUB_STEP_SUMMARY"
          report() {
            local name="$1" result="$2"
            case "$result" in
              success)  echo "| $name | :white_check_mark: Published |" ;;
              skipped)  echo "| $name | :fast_forward: Skipped |" ;;
              *)        echo "| $name | :x: $result |" ;;
            esac
          }
          {
            report "crates.io"       "${{ needs.publish-crates.result }}"
            report "GitHub Release"  "${{ needs.upload-release-assets.result }}"
            report "Homebrew"        "${{ needs.publish-homebrew-bottles.result }}"
          } >> "$GITHUB_STEP_SUMMARY"