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
name: CI
on:
push:
branches:
pull_request:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test & lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-targets -- -D warnings
- run: cargo test
# Runs on every push to master. If the version in Cargo.toml has no matching
# git tag yet, it publishes to crates.io and creates a GitHub release with
# Linux binaries. Bump the version in Cargo.toml to cut a release.
#
# Required repository secret: CARGO_REGISTRY_TOKEN (crates.io API token).
release:
name: Publish & release
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-gnu,x86_64-unknown-linux-musl
- uses: Swatinem/rust-cache@v2
- name: Read crate version
id: version
run: |
V=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
echo "version=$V" >> "$GITHUB_OUTPUT"
- name: Check if this version is already released
id: check
run: |
if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "new=false" >> "$GITHUB_OUTPUT"
echo "v${{ steps.version.outputs.version }} already tagged — nothing to do."
else
echo "new=true" >> "$GITHUB_OUTPUT"
fi
- name: Install musl tools
if: steps.check.outputs.new == 'true'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Build Linux binaries
if: steps.check.outputs.new == 'true'
run: |
cargo build --release --locked --target x86_64-unknown-linux-gnu
cargo build --release --locked --target x86_64-unknown-linux-musl
mkdir -p dist
for target in x86_64-unknown-linux-gnu x86_64-unknown-linux-musl; do
strip "target/$target/release/jsonl-tui"
tar -C "target/$target/release" -czf "dist/jsonl-tui-$target.tar.gz" jsonl-tui
done
(cd dist && sha256sum ./*.tar.gz > SHA256SUMS)
- name: Publish to crates.io
if: steps.check.outputs.new == 'true'
run: cargo publish --locked
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create GitHub release
if: steps.check.outputs.new == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: v${{ steps.version.outputs.version }}
files: |
dist/*.tar.gz
dist/SHA256SUMS
generate_release_notes: true