-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (160 loc) · 5.4 KB
/
release.yml
File metadata and controls
190 lines (160 loc) · 5.4 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
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
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
artifact: cc-statusline-darwin-x86_64
- target: aarch64-apple-darwin
os: macos-latest
artifact: cc-statusline-darwin-arm64
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact: cc-statusline-linux-x86_64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact: cc-statusline-linux-arm64
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build
run: |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
fi
cargo build --release --target ${{ matrix.target }}
- name: Package binary
run: |
mkdir -p dist
cp target/${{ matrix.target }}/release/cc-statusline dist/${{ matrix.artifact }}
cd dist && shasum -a 256 ${{ matrix.artifact }} > ${{ matrix.artifact }}.sha256
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist/*
create-deb:
name: Create .deb package
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
include:
- artifact: cc-statusline-linux-x86_64
arch: amd64
- artifact: cc-statusline-linux-arm64
arch: arm64
steps:
- uses: actions/checkout@v4
- name: Download binary
uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact }}
path: bin
- name: Get version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create .deb package
run: |
VERSION=${{ steps.version.outputs.version }}
ARCH=${{ matrix.arch }}
PKG_NAME=cc-statusline_${VERSION}_${ARCH}
mkdir -p ${PKG_NAME}/DEBIAN
mkdir -p ${PKG_NAME}/usr/bin
chmod +x bin/${{ matrix.artifact }}
cp bin/${{ matrix.artifact }} ${PKG_NAME}/usr/bin/cc-statusline
cat > ${PKG_NAME}/DEBIAN/control << EOF
Package: cc-statusline
Version: ${VERSION}
Section: utils
Priority: optional
Architecture: ${ARCH}
Maintainer: Fazal Khan
Description: Lightweight statusline for Claude Code
Shows context token usage and costs in a colored bar format.
Homepage: https://github.com/Demwunz/cc-statusline
EOF
dpkg-deb --build ${PKG_NAME}
- name: Upload .deb artifact
uses: actions/upload-artifact@v4
with:
name: cc-statusline_${{ steps.version.outputs.version }}_${{ matrix.arch }}.deb
path: "*.deb"
release:
name: Create Release
runs-on: ubuntu-latest
needs: [build, create-deb]
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Flatten artifacts
run: |
mkdir -p release
find artifacts -type f \( -name "cc-statusline-*" -o -name "*.deb" -o -name "*.sha256" \) -exec cp {} release/ \;
ls -la release/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: release/*
generate_release_notes: true
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-homebrew:
name: Update Homebrew Formula
runs-on: ubuntu-latest
needs: release
steps:
- name: Get version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Download checksums
uses: actions/download-artifact@v4
with:
pattern: cc-statusline-darwin-*
path: checksums
merge-multiple: true
- name: Extract checksums
id: checksums
run: |
ARM64_SHA=$(cat checksums/cc-statusline-darwin-arm64.sha256 | awk '{print $1}')
X86_SHA=$(cat checksums/cc-statusline-darwin-x86_64.sha256 | awk '{print $1}')
echo "arm64_sha=${ARM64_SHA}" >> $GITHUB_OUTPUT
echo "x86_sha=${X86_SHA}" >> $GITHUB_OUTPUT
- name: Update Homebrew tap
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
repository: Demwunz/homebrew-tap
event-type: update-formula
client-payload: |
{
"formula": "cc-statusline",
"version": "${{ steps.version.outputs.version }}",
"arm64_sha": "${{ steps.checksums.outputs.arm64_sha }}",
"x86_sha": "${{ steps.checksums.outputs.x86_sha }}"
}