forked from ccusage/ccusage
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (125 loc) · 4.43 KB
/
Copy pathrelease.yaml
File metadata and controls
130 lines (125 loc) · 4.43 KB
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
name: npm publish
on:
push:
tags:
- '*'
jobs:
build-native-packages:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04-arm
platform: linux
arch: arm64
binary: result/bin/ccusage
- os: ubuntu-24.04
platform: linux
arch: x64
binary: result/bin/ccusage
- os: macos-latest
platform: darwin
arch: arm64
binary: rust/target/release/ccusage
- os: macos-15-intel
platform: darwin
arch: x64
binary: rust/target/release/ccusage
- os: windows-11-arm
platform: win32
arch: arm64
binary: rust/target/release/ccusage.exe
- os: windows-latest
platform: win32
arch: x64
binary: rust/target/release/ccusage.exe
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: ./.github/actions/setup-nix
if: matrix.platform == 'linux'
with:
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Cache Cargo build
if: matrix.platform != 'linux'
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
key: cargo-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('rust/Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
cargo-${{ runner.os }}-${{ runner.arch }}-
- name: Build Linux static binary
if: matrix.platform == 'linux'
run: nix build .#ccusage-static
- name: Verify Linux binary is static
if: matrix.platform == 'linux'
shell: bash
run: |
file "${{ matrix.binary }}"
if ldd "${{ matrix.binary }}" > "$RUNNER_TEMP/ldd.txt" 2>&1; then
cat "$RUNNER_TEMP/ldd.txt"
grep -Eiq 'not a dynamic executable|statically linked' "$RUNNER_TEMP/ldd.txt"
else
cat "$RUNNER_TEMP/ldd.txt"
grep -Eiq 'not a dynamic executable|statically linked' "$RUNNER_TEMP/ldd.txt"
fi
- name: Build Cargo native binary
if: matrix.platform != 'linux'
run: cargo build --manifest-path rust/Cargo.toml --release --bin ccusage
- run: node apps/ccusage/scripts/stage-native-package.mjs --platform "${{ matrix.platform }}" --arch "${{ matrix.arch }}" --binary "${{ matrix.binary }}"
- name: Archive native package binary
shell: bash
run: tar -cf "ccusage-native-${{ matrix.platform }}-${{ matrix.arch }}.tar" "packages/ccusage-${{ matrix.platform }}-${{ matrix.arch }}/bin"
- uses: actions/upload-artifact@v4
with:
name: ccusage-native-${{ matrix.platform }}-${{ matrix.arch }}
path: ccusage-native-${{ matrix.platform }}-${{ matrix.arch }}.tar
if-no-files-found: error
npm:
needs:
- build-native-packages
runs-on: ubuntu-24.04-arm
timeout-minutes: 10
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: ./.github/actions/setup-nix
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
registry-url: 'https://registry.npmjs.org'
node-version: lts/*
- uses: actions/download-artifact@v4
with:
pattern: ccusage-native-*
path: ${{ runner.temp }}/native-packages
merge-multiple: true
- name: Restore native package binaries
run: |
for archive in "$RUNNER_TEMP"/native-packages/*.tar; do
tar -xf "$archive"
done
- run: nix develop --command pnpm --filter='./apps/ccusage' --filter='./packages/ccusage-*' publish --provenance --no-git-checks --access public
release:
needs:
- npm
runs-on: ubuntu-24.04-arm
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- uses: ./.github/actions/setup-nix
- run: nix develop --command pnpm changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}