|
| 1 | +name: Release Binaries |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Tag to release (e.g., v0.1.1)' |
| 11 | + required: false |
| 12 | + |
| 13 | +env: |
| 14 | + CARGO_TERM_COLOR: always |
| 15 | + RUST_BACKTRACE: 1 |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + name: Build ${{ matrix.target }} |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + include: |
| 25 | + # macOS Intel |
| 26 | + - target: x86_64-apple-darwin |
| 27 | + os: macos-latest |
| 28 | + binary_name: indra |
| 29 | + archive_name: indra-x86_64-apple-darwin.tar.gz |
| 30 | + |
| 31 | + # macOS Apple Silicon |
| 32 | + - target: aarch64-apple-darwin |
| 33 | + os: macos-latest |
| 34 | + binary_name: indra |
| 35 | + archive_name: indra-aarch64-apple-darwin.tar.gz |
| 36 | + |
| 37 | + # Linux x86_64 (glibc) |
| 38 | + - target: x86_64-unknown-linux-gnu |
| 39 | + os: ubuntu-latest |
| 40 | + binary_name: indra |
| 41 | + archive_name: indra-x86_64-unknown-linux-gnu.tar.gz |
| 42 | + |
| 43 | + # Linux x86_64 (musl - static) |
| 44 | + - target: x86_64-unknown-linux-musl |
| 45 | + os: ubuntu-latest |
| 46 | + binary_name: indra |
| 47 | + archive_name: indra-x86_64-unknown-linux-musl.tar.gz |
| 48 | + |
| 49 | + # Linux ARM64 |
| 50 | + - target: aarch64-unknown-linux-gnu |
| 51 | + os: ubuntu-latest |
| 52 | + binary_name: indra |
| 53 | + archive_name: indra-aarch64-unknown-linux-gnu.tar.gz |
| 54 | + |
| 55 | + # Linux ARM64 (musl) |
| 56 | + - target: aarch64-unknown-linux-musl |
| 57 | + os: ubuntu-latest |
| 58 | + binary_name: indra |
| 59 | + archive_name: indra-aarch64-unknown-linux-musl.tar.gz |
| 60 | + |
| 61 | + # Raspberry Pi (ARMv7) |
| 62 | + - target: armv7-unknown-linux-gnueabihf |
| 63 | + os: ubuntu-latest |
| 64 | + binary_name: indra |
| 65 | + archive_name: indra-armv7-unknown-linux-gnueabihf.tar.gz |
| 66 | + |
| 67 | + # Windows x86_64 |
| 68 | + - target: x86_64-pc-windows-msvc |
| 69 | + os: windows-latest |
| 70 | + binary_name: indra.exe |
| 71 | + archive_name: indra-x86_64-pc-windows-msvc.zip |
| 72 | + |
| 73 | + # Windows ARM64 |
| 74 | + - target: aarch64-pc-windows-msvc |
| 75 | + os: windows-latest |
| 76 | + binary_name: indra.exe |
| 77 | + archive_name: indra-aarch64-pc-windows-msvc.zip |
| 78 | + |
| 79 | + steps: |
| 80 | + - name: Checkout code |
| 81 | + uses: actions/checkout@v4 |
| 82 | + |
| 83 | + - name: Install Rust toolchain |
| 84 | + uses: dtolnay/rust-toolchain@stable |
| 85 | + with: |
| 86 | + targets: ${{ matrix.target }} |
| 87 | + |
| 88 | + - name: Cache cargo registry |
| 89 | + uses: actions/cache@v4 |
| 90 | + with: |
| 91 | + path: ~/.cargo/registry |
| 92 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} |
| 93 | + |
| 94 | + - name: Cache cargo index |
| 95 | + uses: actions/cache@v4 |
| 96 | + with: |
| 97 | + path: ~/.cargo/git |
| 98 | + key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }} |
| 99 | + |
| 100 | + - name: Cache target directory |
| 101 | + uses: actions/cache@v4 |
| 102 | + with: |
| 103 | + path: target |
| 104 | + key: ${{ runner.os }}-${{ matrix.target }}-cargo-target-${{ hashFiles('**/Cargo.lock') }} |
| 105 | + |
| 106 | + - name: Install cross-compilation tools (Linux ARM) |
| 107 | + if: runner.os == 'Linux' && contains(matrix.target, 'aarch64') |
| 108 | + run: | |
| 109 | + sudo apt-get update |
| 110 | + sudo apt-get install -y gcc-aarch64-linux-gnu |
| 111 | +
|
| 112 | + - name: Install cross-compilation tools (Linux ARMv7) |
| 113 | + if: runner.os == 'Linux' && contains(matrix.target, 'armv7') |
| 114 | + run: | |
| 115 | + sudo apt-get update |
| 116 | + sudo apt-get install -y gcc-arm-linux-gnueabihf |
| 117 | +
|
| 118 | + - name: Install musl tools |
| 119 | + if: contains(matrix.target, 'musl') |
| 120 | + run: | |
| 121 | + sudo apt-get update |
| 122 | + sudo apt-get install -y musl-tools |
| 123 | +
|
| 124 | + - name: Build binary |
| 125 | + run: cargo build --release --locked --target ${{ matrix.target }} |
| 126 | + |
| 127 | + - name: Strip binary (Unix) |
| 128 | + if: runner.os != 'Windows' |
| 129 | + run: | |
| 130 | + strip target/${{ matrix.target }}/release/${{ matrix.binary_name }} || true |
| 131 | +
|
| 132 | + - name: Create archive (Unix) |
| 133 | + if: runner.os != 'Windows' |
| 134 | + run: | |
| 135 | + cd target/${{ matrix.target }}/release |
| 136 | + tar czf ../../../${{ matrix.archive_name }} ${{ matrix.binary_name }} |
| 137 | + cd ../../.. |
| 138 | + ls -lh ${{ matrix.archive_name }} |
| 139 | +
|
| 140 | + - name: Create archive (Windows) |
| 141 | + if: runner.os == 'Windows' |
| 142 | + shell: pwsh |
| 143 | + run: | |
| 144 | + cd target/${{ matrix.target }}/release |
| 145 | + Compress-Archive -Path ${{ matrix.binary_name }} -DestinationPath ../../../${{ matrix.archive_name }} |
| 146 | + cd ../../.. |
| 147 | + dir ${{ matrix.archive_name }} |
| 148 | +
|
| 149 | + - name: Generate checksum |
| 150 | + shell: bash |
| 151 | + run: | |
| 152 | + if [ "${{ runner.os }}" = "Windows" ]; then |
| 153 | + certutil -hashfile ${{ matrix.archive_name }} SHA256 | grep -v "SHA256" | grep -v "CertUtil" > ${{ matrix.archive_name }}.sha256 |
| 154 | + else |
| 155 | + shasum -a 256 ${{ matrix.archive_name }} > ${{ matrix.archive_name }}.sha256 |
| 156 | + fi |
| 157 | + cat ${{ matrix.archive_name }}.sha256 |
| 158 | +
|
| 159 | + - name: Upload artifacts |
| 160 | + uses: actions/upload-artifact@v4 |
| 161 | + with: |
| 162 | + name: ${{ matrix.target }} |
| 163 | + path: | |
| 164 | + ${{ matrix.archive_name }} |
| 165 | + ${{ matrix.archive_name }}.sha256 |
| 166 | +
|
| 167 | + release: |
| 168 | + name: Create Release |
| 169 | + needs: build |
| 170 | + runs-on: ubuntu-latest |
| 171 | + permissions: |
| 172 | + contents: write |
| 173 | + steps: |
| 174 | + - name: Checkout code |
| 175 | + uses: actions/checkout@v4 |
| 176 | + |
| 177 | + - name: Download all artifacts |
| 178 | + uses: actions/download-artifact@v4 |
| 179 | + with: |
| 180 | + path: artifacts |
| 181 | + |
| 182 | + - name: Prepare release assets |
| 183 | + run: | |
| 184 | + mkdir release-assets |
| 185 | + find artifacts -type f -exec cp {} release-assets/ \; |
| 186 | + ls -lh release-assets/ |
| 187 | +
|
| 188 | + - name: Extract version from tag |
| 189 | + id: get_version |
| 190 | + run: | |
| 191 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.tag }}" ]; then |
| 192 | + echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT |
| 193 | + else |
| 194 | + echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 195 | + fi |
| 196 | +
|
| 197 | + - name: Create Release |
| 198 | + uses: softprops/action-gh-release@v2 |
| 199 | + with: |
| 200 | + tag_name: ${{ steps.get_version.outputs.version }} |
| 201 | + name: Release ${{ steps.get_version.outputs.version }} |
| 202 | + draft: false |
| 203 | + prerelease: false |
| 204 | + files: release-assets/* |
| 205 | + body: | |
| 206 | + ## indra_db ${{ steps.get_version.outputs.version }} |
| 207 | +
|
| 208 | + ### Installation |
| 209 | +
|
| 210 | + **Via cargo:** |
| 211 | + ```bash |
| 212 | + cargo install indra_db |
| 213 | + ``` |
| 214 | +
|
| 215 | + **Via prebuilt binary:** |
| 216 | + Download the appropriate binary for your platform below, extract it, and add to your PATH. |
| 217 | +
|
| 218 | + ### Binaries |
| 219 | +
|
| 220 | + - **macOS Intel**: `indra-x86_64-apple-darwin.tar.gz` |
| 221 | + - **macOS Apple Silicon**: `indra-aarch64-apple-darwin.tar.gz` |
| 222 | + - **Linux x86_64 (glibc)**: `indra-x86_64-unknown-linux-gnu.tar.gz` |
| 223 | + - **Linux x86_64 (musl/static)**: `indra-x86_64-unknown-linux-musl.tar.gz` |
| 224 | + - **Linux ARM64**: `indra-aarch64-unknown-linux-gnu.tar.gz` |
| 225 | + - **Linux ARM64 (musl)**: `indra-aarch64-unknown-linux-musl.tar.gz` |
| 226 | + - **Raspberry Pi (ARMv7)**: `indra-armv7-unknown-linux-gnueabihf.tar.gz` |
| 227 | + - **Windows x86_64**: `indra-x86_64-pc-windows-msvc.zip` |
| 228 | + - **Windows ARM64**: `indra-aarch64-pc-windows-msvc.zip` |
| 229 | +
|
| 230 | + SHA256 checksums are provided for verification. |
| 231 | +
|
| 232 | + ### Usage |
| 233 | +
|
| 234 | + ```bash |
| 235 | + indra --help |
| 236 | + ``` |
| 237 | +
|
| 238 | + See [README](https://github.com/moonstripe/indra_db#readme) for full documentation. |
| 239 | + env: |
| 240 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments