-
Notifications
You must be signed in to change notification settings - Fork 0
254 lines (213 loc) · 7.81 KB
/
Copy pathrelease.yml
File metadata and controls
254 lines (213 loc) · 7.81 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: Release Binaries
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., v0.1.1)'
required: false
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# macOS Intel
- target: x86_64-apple-darwin
os: macos-latest
binary_name: indra
archive_name: indra-x86_64-apple-darwin.tar.gz
use_cross: false
# macOS Apple Silicon
- target: aarch64-apple-darwin
os: macos-latest
binary_name: indra
archive_name: indra-aarch64-apple-darwin.tar.gz
use_cross: false
# Linux x86_64 (glibc)
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
binary_name: indra
archive_name: indra-x86_64-unknown-linux-gnu.tar.gz
use_cross: false
# Linux x86_64 (musl - static)
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
binary_name: indra
archive_name: indra-x86_64-unknown-linux-musl.tar.gz
use_cross: true
# Linux ARM64 - use cross for proper sysroot
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
binary_name: indra
archive_name: indra-aarch64-unknown-linux-gnu.tar.gz
use_cross: true
# Linux ARM64 (musl)
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
binary_name: indra
archive_name: indra-aarch64-unknown-linux-musl.tar.gz
use_cross: true
# Windows x86_64
- target: x86_64-pc-windows-msvc
os: windows-latest
binary_name: indra.exe
archive_name: indra-x86_64-pc-windows-msvc.zip
use_cross: false
# Windows ARM64
- target: aarch64-pc-windows-msvc
os: windows-latest
binary_name: indra.exe
archive_name: indra-aarch64-pc-windows-msvc.zip
use_cross: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
- name: Cache target directory
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-${{ matrix.target }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
- name: Install cross
if: matrix.use_cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install musl tools (native musl build)
if: matrix.target == 'x86_64-unknown-linux-musl' && !matrix.use_cross
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Build binary (cross)
if: matrix.use_cross
run: cross build --release --locked --target ${{ matrix.target }}
- name: Build binary (native)
if: "!matrix.use_cross"
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Strip binary (Unix)
if: runner.os != 'Windows'
run: |
strip target/${{ matrix.target }}/release/${{ matrix.binary_name }} || true
- name: Create archive (Unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../${{ matrix.archive_name }} ${{ matrix.binary_name }}
cd ../../..
ls -lh ${{ matrix.archive_name }}
- name: Create archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Path ${{ matrix.binary_name }} -DestinationPath ../../../${{ matrix.archive_name }}
cd ../../..
dir ${{ matrix.archive_name }}
- name: Generate checksum
shell: bash
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
certutil -hashfile ${{ matrix.archive_name }} SHA256 | grep -v "SHA256" | grep -v "CertUtil" > ${{ matrix.archive_name }}.sha256
else
shasum -a 256 ${{ matrix.archive_name }} > ${{ matrix.archive_name }}.sha256
fi
cat ${{ matrix.archive_name }}.sha256
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: |
${{ matrix.archive_name }}
${{ matrix.archive_name }}.sha256
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir release-assets
find artifacts -type f -exec cp {} release-assets/ \;
ls -lh release-assets/
- name: Extract version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.tag }}" ]; then
echo "version=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.version }}
name: Release ${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
files: release-assets/*
body: |
## indra_db ${{ steps.get_version.outputs.version }}
### Installation
**Via cargo:**
```bash
cargo install indra_db
```
**Via prebuilt binary:**
Download the appropriate binary for your platform below, extract it, and add to your PATH.
### Binaries
- **macOS Intel**: `indra-x86_64-apple-darwin.tar.gz`
- **macOS Apple Silicon**: `indra-aarch64-apple-darwin.tar.gz`
- **Linux x86_64 (glibc)**: `indra-x86_64-unknown-linux-gnu.tar.gz`
- **Linux x86_64 (musl/static)**: `indra-x86_64-unknown-linux-musl.tar.gz`
- **Linux ARM64**: `indra-aarch64-unknown-linux-gnu.tar.gz`
- **Linux ARM64 (musl)**: `indra-aarch64-unknown-linux-musl.tar.gz`
- **Windows x86_64**: `indra-x86_64-pc-windows-msvc.zip`
- **Windows ARM64**: `indra-aarch64-pc-windows-msvc.zip`
SHA256 checksums are provided for verification.
### Usage
```bash
indra --help
```
See [README](https://github.com/moonstripe/indra_db#readme) for full documentation.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-crates:
name: Publish to crates.io
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}