headroom 1.5.1

Audio loudness analyzer and gain adjustment tool for mastering workflows
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
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

jobs:
  # =============================================================================
  # Build Jobs
  # =============================================================================

  build-macos:
    runs-on: macos-latest
    steps:
      - name: Checkout
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable
        with:
          toolchain: stable

      - name: Add targets
        run: |
          rustup target add aarch64-apple-darwin
          rustup target add x86_64-apple-darwin

      - name: Build arm64
        run: cargo build --release --target aarch64-apple-darwin

      - name: Build x86_64
        run: cargo build --release --target x86_64-apple-darwin

      - name: Create universal binary
        run: |
          mkdir -p release
          lipo -create \
            target/aarch64-apple-darwin/release/headroom \
            target/x86_64-apple-darwin/release/headroom \
            -output release/headroom

      - name: Get version
        id: version
        run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

      - name: Create tarball
        run: |
          cd release
          tar -czvf headroom-${{ steps.version.outputs.VERSION }}-macos-universal.tar.gz headroom

      - name: Calculate SHA256
        id: sha256
        run: |
          SHA256=$(shasum -a 256 release/headroom-${{ steps.version.outputs.VERSION }}-macos-universal.tar.gz | awk '{print $1}')
          echo "SHA256=$SHA256" >> $GITHUB_OUTPUT

      - name: Upload artifact
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        with:
          name: macos-universal
          path: release/headroom-${{ steps.version.outputs.VERSION }}-macos-universal.tar.gz

      - name: Save SHA256
        run: echo "${{ steps.sha256.outputs.SHA256 }}" > sha256-macos-universal.txt

      - name: Upload SHA256
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        with:
          name: sha256-macos-universal
          path: sha256-macos-universal.txt

  build-linux-x86_64:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable
        with:
          toolchain: stable

      - name: Build
        run: cargo build --release

      - name: Get version
        id: version
        run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

      - name: Create tarball
        run: |
          mkdir -p release
          cp target/release/headroom release/
          cd release
          tar -czvf headroom-${{ steps.version.outputs.VERSION }}-linux-x86_64.tar.gz headroom

      - name: Calculate SHA256
        id: sha256
        run: |
          SHA256=$(sha256sum release/headroom-${{ steps.version.outputs.VERSION }}-linux-x86_64.tar.gz | awk '{print $1}')
          echo "SHA256=$SHA256" >> $GITHUB_OUTPUT

      - name: Upload artifact
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        with:
          name: linux-x86_64
          path: release/headroom-${{ steps.version.outputs.VERSION }}-linux-x86_64.tar.gz

      - name: Save SHA256
        run: echo "${{ steps.sha256.outputs.SHA256 }}" > sha256-linux-x86_64.txt

      - name: Upload SHA256
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        with:
          name: sha256-linux-x86_64
          path: sha256-linux-x86_64.txt

  build-linux-aarch64:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable
        with:
          toolchain: stable

      - name: Install cross
        run: cargo install cross --git https://github.com/cross-rs/cross

      - name: Build with cross
        run: cross build --release --target aarch64-unknown-linux-gnu

      - name: Get version
        id: version
        run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

      - name: Create tarball
        run: |
          mkdir -p release
          cp target/aarch64-unknown-linux-gnu/release/headroom release/
          cd release
          tar -czvf headroom-${{ steps.version.outputs.VERSION }}-linux-aarch64.tar.gz headroom

      - name: Calculate SHA256
        id: sha256
        run: |
          SHA256=$(sha256sum release/headroom-${{ steps.version.outputs.VERSION }}-linux-aarch64.tar.gz | awk '{print $1}')
          echo "SHA256=$SHA256" >> $GITHUB_OUTPUT

      - name: Upload artifact
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        with:
          name: linux-aarch64
          path: release/headroom-${{ steps.version.outputs.VERSION }}-linux-aarch64.tar.gz

      - name: Save SHA256
        run: echo "${{ steps.sha256.outputs.SHA256 }}" > sha256-linux-aarch64.txt

      - name: Upload SHA256
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        with:
          name: sha256-linux-aarch64
          path: sha256-linux-aarch64.txt

  build-windows:
    runs-on: windows-latest
    steps:
      - name: Checkout
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable
        with:
          toolchain: stable

      - name: Build
        run: cargo build --release

      - name: Get version
        id: version
        shell: bash
        run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

      - name: Create zip
        shell: pwsh
        run: |
          New-Item -ItemType Directory -Force -Path release
          Copy-Item target\release\headroom.exe release\
          Compress-Archive -Path release\headroom.exe -DestinationPath release\headroom-${{ steps.version.outputs.VERSION }}-windows-x86_64.zip

      - name: Calculate SHA256
        id: sha256
        shell: pwsh
        run: |
          $hash = (Get-FileHash release\headroom-${{ steps.version.outputs.VERSION }}-windows-x86_64.zip -Algorithm SHA256).Hash.ToLower()
          echo "SHA256=$hash" >> $env:GITHUB_OUTPUT

      - name: Upload artifact
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        with:
          name: windows-x86_64
          path: release/headroom-${{ steps.version.outputs.VERSION }}-windows-x86_64.zip

      - name: Save SHA256
        shell: bash
        run: echo "${{ steps.sha256.outputs.SHA256 }}" > sha256-windows-x86_64.txt

      - name: Upload SHA256
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
        with:
          name: sha256-windows-x86_64
          path: sha256-windows-x86_64.txt

  # =============================================================================
  # Release Job - Create GitHub Release
  # =============================================================================

  release:
    needs: [build-macos, build-linux-x86_64, build-linux-aarch64, build-windows]
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.version.outputs.VERSION }}
      version_num: ${{ steps.version.outputs.VERSION_NUM }}
      macos_sha256: ${{ steps.macos_sha256.outputs.SHA256 }}
      windows_sha256: ${{ steps.windows_sha256.outputs.SHA256 }}
    steps:
      - name: Checkout
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

      - name: Get version
        id: version
        run: |
          VERSION="${GITHUB_REF#refs/tags/}"
          echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
          echo "VERSION_NUM=${VERSION#v}" >> $GITHUB_OUTPUT

      - name: Download all artifacts
        uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
        with:
          path: artifacts

      - name: Prepare release files
        run: |
          mkdir -p release
          mv artifacts/macos-universal/*.tar.gz release/
          mv artifacts/linux-x86_64/*.tar.gz release/
          mv artifacts/linux-aarch64/*.tar.gz release/
          mv artifacts/windows-x86_64/*.zip release/

      - name: Create checksums file
        run: |
          cd release
          cat ../artifacts/sha256-macos-universal/sha256-macos-universal.txt | while read hash; do echo "$hash  headroom-${{ steps.version.outputs.VERSION }}-macos-universal.tar.gz"; done > checksums.txt
          cat ../artifacts/sha256-linux-x86_64/sha256-linux-x86_64.txt | while read hash; do echo "$hash  headroom-${{ steps.version.outputs.VERSION }}-linux-x86_64.tar.gz"; done >> checksums.txt
          cat ../artifacts/sha256-linux-aarch64/sha256-linux-aarch64.txt | while read hash; do echo "$hash  headroom-${{ steps.version.outputs.VERSION }}-linux-aarch64.tar.gz"; done >> checksums.txt
          cat ../artifacts/sha256-windows-x86_64/sha256-windows-x86_64.txt | while read hash; do echo "$hash  headroom-${{ steps.version.outputs.VERSION }}-windows-x86_64.zip"; done >> checksums.txt
          mv checksums.txt headroom-${{ steps.version.outputs.VERSION }}-checksums.txt

      - name: Get macOS SHA256
        id: macos_sha256
        run: |
          SHA256=$(cat artifacts/sha256-macos-universal/sha256-macos-universal.txt)
          echo "SHA256=$SHA256" >> $GITHUB_OUTPUT

      - name: Get Windows SHA256
        id: windows_sha256
        run: |
          SHA256=$(cat artifacts/sha256-windows-x86_64/sha256-windows-x86_64.txt)
          echo "SHA256=$SHA256" >> $GITHUB_OUTPUT

      - name: Check for release notes
        id: release_notes
        run: |
          if [ -f "RELEASE_NOTES.md" ]; then
            echo "exists=true" >> $GITHUB_OUTPUT
          else
            echo "exists=false" >> $GITHUB_OUTPUT
          fi

      - name: Create Release (with custom notes)
        if: steps.release_notes.outputs.exists == 'true'
        uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2
        with:
          files: |
            release/headroom-${{ steps.version.outputs.VERSION }}-macos-universal.tar.gz
            release/headroom-${{ steps.version.outputs.VERSION }}-linux-x86_64.tar.gz
            release/headroom-${{ steps.version.outputs.VERSION }}-linux-aarch64.tar.gz
            release/headroom-${{ steps.version.outputs.VERSION }}-windows-x86_64.zip
            release/headroom-${{ steps.version.outputs.VERSION }}-checksums.txt
          body_path: RELEASE_NOTES.md
          append_body: true

      - name: Create Release (auto-generated notes)
        if: steps.release_notes.outputs.exists == 'false'
        uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2
        with:
          files: |
            release/headroom-${{ steps.version.outputs.VERSION }}-macos-universal.tar.gz
            release/headroom-${{ steps.version.outputs.VERSION }}-linux-x86_64.tar.gz
            release/headroom-${{ steps.version.outputs.VERSION }}-linux-aarch64.tar.gz
            release/headroom-${{ steps.version.outputs.VERSION }}-windows-x86_64.zip
            release/headroom-${{ steps.version.outputs.VERSION }}-checksums.txt
          generate_release_notes: true
          body: |
            ## Installation

            | Platform | Command |
            |----------|---------|
            | **macOS (Homebrew)** | `brew install M-Igashi/tap/headroom` |
            | **Windows (Scoop)** | `scoop bucket add headroom https://github.com/M-Igashi/scoop-bucket && scoop install headroom` |
            | **Windows (winget)** | `winget install M-Igashi.headroom` |
            | **Cargo** | `cargo install headroom` |

            **Dependencies:** ffmpeg and mp3rgain must be installed separately.

            ## Checksums
            See `headroom-${{ steps.version.outputs.VERSION }}-checksums.txt` for SHA256 checksums of all binaries.

            ## Note
            mp3rgain is now built-in as a library dependency. No separate installation required.

  # =============================================================================
  # Publish to Cargo (crates.io)
  # =============================================================================

  publish-cargo:
    needs: [release]
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable
        with:
          toolchain: stable

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish --token $CARGO_REGISTRY_TOKEN

  # =============================================================================
  # Update Homebrew (macOS)
  # =============================================================================

  update-homebrew:
    needs: [release]
    runs-on: ubuntu-latest
    steps:
      - name: Update Homebrew formula
        env:
          HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
        run: |
          VERSION="${{ needs.release.outputs.version }}"
          VERSION_NUM="${{ needs.release.outputs.version_num }}"
          SHA256="${{ needs.release.outputs.macos_sha256 }}"

          git clone https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/M-Igashi/homebrew-tap.git
          cd homebrew-tap

          cat > Formula/headroom.rb << 'FORMULA'
          class Headroom < Formula
            desc "Audio loudness analyzer and gain adjustment tool for mastering and DJ workflows"
            homepage "https://github.com/M-Igashi/headroom"
            url "https://github.com/M-Igashi/headroom/releases/download/VERSION_PLACEHOLDER/headroom-VERSION_PLACEHOLDER-macos-universal.tar.gz"
            sha256 "SHA256_PLACEHOLDER"
            version "VERSION_NUM_PLACEHOLDER"
            license "MIT"

            depends_on "ffmpeg"

            def install
              bin.install "headroom"
            end

            def caveats
              <<~EOS
                mp3rgain is now built-in as a library dependency.
                No separate installation required for lossless MP3 gain adjustment.
              EOS
            end

            test do
              assert_match "headroom", shell_output("#{bin}/headroom --version")
            end
          end
          FORMULA

          sed -i "s|VERSION_PLACEHOLDER|${VERSION}|g" Formula/headroom.rb
          sed -i "s|SHA256_PLACEHOLDER|${SHA256}|g" Formula/headroom.rb
          sed -i "s|VERSION_NUM_PLACEHOLDER|${VERSION_NUM}|g" Formula/headroom.rb

          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add Formula/headroom.rb
          git commit -m "headroom ${VERSION_NUM}"
          git push

  # =============================================================================
  # Update Scoop (Windows)
  # =============================================================================

  update-scoop:
    needs: [release]
    runs-on: ubuntu-latest
    steps:
      - name: Update Scoop bucket
        env:
          SCOOP_BUCKET_TOKEN: ${{ secrets.SCOOP_BUCKET_TOKEN }}
        run: |
          VERSION="${{ needs.release.outputs.version }}"
          VERSION_NUM="${{ needs.release.outputs.version_num }}"
          SHA256="${{ needs.release.outputs.windows_sha256 }}"

          git clone https://x-access-token:${SCOOP_BUCKET_TOKEN}@github.com/M-Igashi/scoop-bucket.git
          cd scoop-bucket

          cat > bucket/headroom.json << MANIFEST
          {
              "version": "${VERSION_NUM}",
              "description": "Audio loudness analyzer and gain adjustment tool for mastering and DJ workflows",
              "homepage": "https://github.com/M-Igashi/headroom",
              "license": "MIT",
              "architecture": {
                  "64bit": {
                      "url": "https://github.com/M-Igashi/headroom/releases/download/${VERSION}/headroom-${VERSION}-windows-x86_64.zip",
                      "hash": "${SHA256}",
                      "bin": "headroom.exe"
                  }
              },
              "depends": "ffmpeg",
              "notes": "mp3rgain is now built-in as a library dependency. No separate installation required.",
              "checkver": {
                  "github": "https://github.com/M-Igashi/headroom"
              },
              "autoupdate": {
                  "architecture": {
                      "64bit": {
                          "url": "https://github.com/M-Igashi/headroom/releases/download/v\$version/headroom-v\$version-windows-x86_64.zip"
                      }
                  }
              }
          }
          MANIFEST

          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add bucket/headroom.json
          git commit -m "headroom ${VERSION_NUM}"
          git push