|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Build ${{ matrix.target }} |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - target: x86_64-apple-darwin |
| 23 | + os: macos-latest |
| 24 | + artifact: cc-statusline-darwin-x86_64 |
| 25 | + - target: aarch64-apple-darwin |
| 26 | + os: macos-latest |
| 27 | + artifact: cc-statusline-darwin-arm64 |
| 28 | + - target: x86_64-unknown-linux-gnu |
| 29 | + os: ubuntu-latest |
| 30 | + artifact: cc-statusline-linux-x86_64 |
| 31 | + - target: aarch64-unknown-linux-gnu |
| 32 | + os: ubuntu-latest |
| 33 | + artifact: cc-statusline-linux-arm64 |
| 34 | + |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: Install Rust toolchain |
| 39 | + uses: dtolnay/rust-toolchain@stable |
| 40 | + with: |
| 41 | + targets: ${{ matrix.target }} |
| 42 | + |
| 43 | + - name: Install cross-compilation tools (Linux ARM64) |
| 44 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 45 | + run: | |
| 46 | + sudo apt-get update |
| 47 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 48 | +
|
| 49 | + - name: Build |
| 50 | + run: | |
| 51 | + if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then |
| 52 | + export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc |
| 53 | + fi |
| 54 | + cargo build --release --target ${{ matrix.target }} |
| 55 | +
|
| 56 | + - name: Package binary |
| 57 | + run: | |
| 58 | + mkdir -p dist |
| 59 | + cp target/${{ matrix.target }}/release/cc-statusline dist/${{ matrix.artifact }} |
| 60 | + cd dist && shasum -a 256 ${{ matrix.artifact }} > ${{ matrix.artifact }}.sha256 |
| 61 | +
|
| 62 | + - name: Upload artifact |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: ${{ matrix.artifact }} |
| 66 | + path: dist/* |
| 67 | + |
| 68 | + create-deb: |
| 69 | + name: Create .deb package |
| 70 | + runs-on: ubuntu-latest |
| 71 | + needs: build |
| 72 | + strategy: |
| 73 | + matrix: |
| 74 | + include: |
| 75 | + - artifact: cc-statusline-linux-x86_64 |
| 76 | + arch: amd64 |
| 77 | + - artifact: cc-statusline-linux-arm64 |
| 78 | + arch: arm64 |
| 79 | + |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + |
| 83 | + - name: Download binary |
| 84 | + uses: actions/download-artifact@v4 |
| 85 | + with: |
| 86 | + name: ${{ matrix.artifact }} |
| 87 | + path: bin |
| 88 | + |
| 89 | + - name: Get version |
| 90 | + id: version |
| 91 | + run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 92 | + |
| 93 | + - name: Create .deb package |
| 94 | + run: | |
| 95 | + VERSION=${{ steps.version.outputs.version }} |
| 96 | + ARCH=${{ matrix.arch }} |
| 97 | + PKG_NAME=cc-statusline_${VERSION}_${ARCH} |
| 98 | +
|
| 99 | + mkdir -p ${PKG_NAME}/DEBIAN |
| 100 | + mkdir -p ${PKG_NAME}/usr/bin |
| 101 | +
|
| 102 | + chmod +x bin/${{ matrix.artifact }} |
| 103 | + cp bin/${{ matrix.artifact }} ${PKG_NAME}/usr/bin/cc-statusline |
| 104 | +
|
| 105 | + cat > ${PKG_NAME}/DEBIAN/control << EOF |
| 106 | + Package: cc-statusline |
| 107 | + Version: ${VERSION} |
| 108 | + Section: utils |
| 109 | + Priority: optional |
| 110 | + Architecture: ${ARCH} |
| 111 | + Maintainer: Fazal Khan |
| 112 | + Description: Lightweight statusline for Claude Code |
| 113 | + Shows context token usage and costs in a colored bar format. |
| 114 | + Homepage: https://github.com/Demwunz/cc-statusline |
| 115 | + EOF |
| 116 | +
|
| 117 | + dpkg-deb --build ${PKG_NAME} |
| 118 | +
|
| 119 | + - name: Upload .deb artifact |
| 120 | + uses: actions/upload-artifact@v4 |
| 121 | + with: |
| 122 | + name: cc-statusline_${{ steps.version.outputs.version }}_${{ matrix.arch }}.deb |
| 123 | + path: "*.deb" |
| 124 | + |
| 125 | + release: |
| 126 | + name: Create Release |
| 127 | + runs-on: ubuntu-latest |
| 128 | + needs: [build, create-deb] |
| 129 | + |
| 130 | + steps: |
| 131 | + - uses: actions/checkout@v4 |
| 132 | + |
| 133 | + - name: Download all artifacts |
| 134 | + uses: actions/download-artifact@v4 |
| 135 | + with: |
| 136 | + path: artifacts |
| 137 | + |
| 138 | + - name: Flatten artifacts |
| 139 | + run: | |
| 140 | + mkdir -p release |
| 141 | + find artifacts -type f \( -name "cc-statusline-*" -o -name "*.deb" -o -name "*.sha256" \) -exec cp {} release/ \; |
| 142 | + ls -la release/ |
| 143 | +
|
| 144 | + - name: Create Release |
| 145 | + uses: softprops/action-gh-release@v2 |
| 146 | + with: |
| 147 | + files: release/* |
| 148 | + generate_release_notes: true |
| 149 | + draft: false |
| 150 | + env: |
| 151 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 152 | + |
| 153 | + update-homebrew: |
| 154 | + name: Update Homebrew Formula |
| 155 | + runs-on: ubuntu-latest |
| 156 | + needs: release |
| 157 | + |
| 158 | + steps: |
| 159 | + - name: Get version |
| 160 | + id: version |
| 161 | + run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 162 | + |
| 163 | + - name: Download checksums |
| 164 | + uses: actions/download-artifact@v4 |
| 165 | + with: |
| 166 | + pattern: cc-statusline-darwin-* |
| 167 | + path: checksums |
| 168 | + merge-multiple: true |
| 169 | + |
| 170 | + - name: Extract checksums |
| 171 | + id: checksums |
| 172 | + run: | |
| 173 | + ARM64_SHA=$(cat checksums/cc-statusline-darwin-arm64.sha256 | awk '{print $1}') |
| 174 | + X86_SHA=$(cat checksums/cc-statusline-darwin-x86_64.sha256 | awk '{print $1}') |
| 175 | + echo "arm64_sha=${ARM64_SHA}" >> $GITHUB_OUTPUT |
| 176 | + echo "x86_sha=${X86_SHA}" >> $GITHUB_OUTPUT |
| 177 | +
|
| 178 | + - name: Update Homebrew tap |
| 179 | + uses: peter-evans/repository-dispatch@v3 |
| 180 | + with: |
| 181 | + token: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 182 | + repository: Demwunz/homebrew-tap |
| 183 | + event-type: update-formula |
| 184 | + client-payload: | |
| 185 | + { |
| 186 | + "formula": "cc-statusline", |
| 187 | + "version": "${{ steps.version.outputs.version }}", |
| 188 | + "arm64_sha": "${{ steps.checksums.outputs.arm64_sha }}", |
| 189 | + "x86_sha": "${{ steps.checksums.outputs.x86_sha }}" |
| 190 | + } |
0 commit comments