Skip to content

Commit 4fbaf4c

Browse files
committed
ci: keep darwin package builds on cargo
Darwin npm optional dependency packages already worked when built by Cargo on the GitHub macOS runners. Building those distribution binaries with Nix introduced Nix store dylib references, which made the pkg.pr.new macOS E2E fail outside a Nix environment and risked extra packaging complexity. Limit Nix native package builds to Linux static artifacts, where they replace the uncached musl setup. Darwin and Windows now share the Cargo build path with the same Cargo registry, git, and target cache, while the flake still supports nix run and Nix-built Darwin packages for Nix users.
1 parent 313045c commit 4fbaf4c

3 files changed

Lines changed: 15 additions & 23 deletions

File tree

‎.github/workflows/ci.yaml‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ jobs:
4444
- os: macos-latest
4545
platform: darwin
4646
arch: arm64
47-
binary: result/bin/ccusage
47+
binary: rust/target/release/ccusage
4848
- os: macos-15-intel
4949
platform: darwin
5050
arch: x64
51-
binary: result/bin/ccusage
51+
binary: rust/target/release/ccusage
5252
- os: windows-11-arm
5353
platform: win32
5454
arch: arm64
@@ -61,11 +61,11 @@ jobs:
6161
steps:
6262
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6363
- uses: ./.github/actions/setup-nix
64-
if: matrix.platform != 'win32'
64+
if: matrix.platform == 'linux'
6565
with:
6666
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
67-
- name: Cache Windows Cargo build
68-
if: matrix.platform == 'win32'
67+
- name: Cache Cargo build
68+
if: matrix.platform != 'linux'
6969
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
7070
with:
7171
path: |
@@ -90,11 +90,8 @@ jobs:
9090
cat "$RUNNER_TEMP/ldd.txt"
9191
grep -Eiq 'not a dynamic executable|statically linked' "$RUNNER_TEMP/ldd.txt"
9292
fi
93-
- name: Build Darwin native binary
94-
if: matrix.platform == 'darwin'
95-
run: nix build .#ccusage
96-
- name: Build Windows native binary
97-
if: matrix.platform == 'win32'
93+
- name: Build Cargo native binary
94+
if: matrix.platform != 'linux'
9895
run: cargo build --manifest-path rust/Cargo.toml --release --bin ccusage
9996
- run: node apps/ccusage/scripts/stage-native-package.mjs --platform "${{ matrix.platform }}" --arch "${{ matrix.arch }}" --binary "${{ matrix.binary }}"
10097
- name: Archive native package binary

‎.github/workflows/release.yaml‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
- os: macos-latest
2525
platform: darwin
2626
arch: arm64
27-
binary: result/bin/ccusage
27+
binary: rust/target/release/ccusage
2828
- os: macos-15-intel
2929
platform: darwin
3030
arch: x64
31-
binary: result/bin/ccusage
31+
binary: rust/target/release/ccusage
3232
- os: windows-11-arm
3333
platform: win32
3434
arch: arm64
@@ -43,11 +43,11 @@ jobs:
4343
with:
4444
fetch-depth: 0
4545
- uses: ./.github/actions/setup-nix
46-
if: matrix.platform != 'win32'
46+
if: matrix.platform == 'linux'
4747
with:
4848
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
49-
- name: Cache Windows Cargo build
50-
if: matrix.platform == 'win32'
49+
- name: Cache Cargo build
50+
if: matrix.platform != 'linux'
5151
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
5252
with:
5353
path: |
@@ -72,11 +72,8 @@ jobs:
7272
cat "$RUNNER_TEMP/ldd.txt"
7373
grep -Eiq 'not a dynamic executable|statically linked' "$RUNNER_TEMP/ldd.txt"
7474
fi
75-
- name: Build Darwin native binary
76-
if: matrix.platform == 'darwin'
77-
run: nix build .#ccusage
78-
- name: Build Windows native binary
79-
if: matrix.platform == 'win32'
75+
- name: Build Cargo native binary
76+
if: matrix.platform != 'linux'
8077
run: cargo build --manifest-path rust/Cargo.toml --release --bin ccusage
8178
- run: node apps/ccusage/scripts/stage-native-package.mjs --platform "${{ matrix.platform }}" --arch "${{ matrix.arch }}" --binary "${{ matrix.binary }}"
8279
- name: Archive native package binary

‎flake.nix‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,12 @@
6666
];
6767
buildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
6868
pkgs.apple-sdk_15
69+
pkgs.libiconv
6970
];
7071
};
7172
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
7273
ccusage = craneLib.buildPackage (commonArgs // {
7374
inherit cargoArtifacts;
74-
postInstall = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
75-
install_name_tool -change "${pkgs.libiconv}/lib/libiconv.2.dylib" "/usr/lib/libiconv.2.dylib" "$out/bin/ccusage"
76-
'';
7775
meta = {
7876
description = "Analyze coding agent CLI token usage and costs from local data";
7977
homepage = "https://github.com/ryoppippi/ccusage";

0 commit comments

Comments
 (0)