Skip to content

Commit 7b7b260

Browse files
committed
Add cross-platform release workflow
1 parent 7102187 commit 7b7b260

3 files changed

Lines changed: 124 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
quality-and-tests:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v5
1616

1717
- name: Install stable Rust toolchain
1818
uses: dtolnay/rust-toolchain@stable

‎.github/workflows/release.yml‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*.*.*"]
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
build:
15+
name: Build ${{ matrix.target }}
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: true
19+
matrix:
20+
include:
21+
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest, smoke: true }
22+
- { target: aarch64-unknown-linux-musl, os: ubuntu-24.04-arm, smoke: true }
23+
- { target: x86_64-apple-darwin, os: macos-latest, smoke: false }
24+
- { target: aarch64-apple-darwin, os: macos-latest, smoke: true }
25+
- { target: x86_64-pc-windows-msvc, os: windows-latest, smoke: true }
26+
steps:
27+
- uses: actions/checkout@v5
28+
29+
- name: Verify tag matches Cargo.toml version
30+
shell: bash
31+
run: |
32+
crate_version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)"
33+
if [ "v${crate_version}" != "${GITHUB_REF_NAME}" ]; then
34+
echo "Tag ${GITHUB_REF_NAME} does not match Cargo.toml version ${crate_version}" >&2
35+
exit 1
36+
fi
37+
38+
- name: Install stable Rust toolchain
39+
uses: dtolnay/rust-toolchain@stable
40+
with:
41+
targets: ${{ matrix.target }}
42+
43+
- name: Install musl tools
44+
if: contains(matrix.target, 'musl')
45+
run: sudo apt-get update && sudo apt-get install -y musl-tools
46+
47+
- name: Build release binary
48+
run: cargo build --release --locked --target ${{ matrix.target }}
49+
50+
- name: Smoke-test binary
51+
if: matrix.smoke
52+
shell: bash
53+
run: |
54+
bin="target/${{ matrix.target }}/release/netdift"
55+
"$bin" --version
56+
"$bin" bench --sessions 2
57+
58+
- name: Package archive
59+
shell: bash
60+
run: |
61+
name="netdift-${GITHUB_REF_NAME}-${{ matrix.target }}"
62+
mkdir -p "dist/${name}"
63+
cp README.md LICENSE CHANGELOG.md SECURITY.md "dist/${name}/"
64+
mkdir -p "dist/${name}/policies"
65+
cp policies/default_policy.yaml "dist/${name}/policies/"
66+
if [[ "${{ matrix.target }}" == *windows* ]]; then
67+
cp "target/${{ matrix.target }}/release/netdift.exe" "dist/${name}/"
68+
(cd dist && 7z a -tzip "${name}.zip" "${name}" > /dev/null)
69+
else
70+
cp "target/${{ matrix.target }}/release/netdift" "dist/${name}/"
71+
(cd dist && tar -czf "${name}.tar.gz" "${name}")
72+
fi
73+
rm -rf "dist/${name}"
74+
ls -l dist
75+
76+
- uses: actions/upload-artifact@v4
77+
with:
78+
name: netdift-${{ matrix.target }}
79+
path: dist/*
80+
if-no-files-found: error
81+
82+
release:
83+
name: Publish GitHub Release (draft)
84+
needs: build
85+
runs-on: ubuntu-latest
86+
permissions:
87+
contents: write
88+
steps:
89+
- uses: actions/download-artifact@v4
90+
with:
91+
path: dist
92+
merge-multiple: true
93+
94+
- name: Generate SHA256SUMS.txt
95+
run: |
96+
cd dist
97+
sha256sum -- * > SHA256SUMS.txt
98+
cat SHA256SUMS.txt
99+
100+
- name: Create draft release with assets
101+
env:
102+
GH_TOKEN: ${{ github.token }}
103+
run: |
104+
gh release create "${GITHUB_REF_NAME}" dist/* \
105+
--repo "${GITHUB_REPOSITORY}" \
106+
--verify-tag \
107+
--draft \
108+
--title "NetDIFT ${GITHUB_REF_NAME}" \
109+
--notes "Release notes pending maintainer review."

‎README.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ For the formal lattice laws, cryptographic header specifications, and threat mod
5454

5555
## Quickstart
5656

57+
### Pre-built binaries
58+
59+
Download a release archive for Linux (static musl, `x86_64`/`aarch64`), macOS (`x86_64`/`arm64`),
60+
or Windows (`x86_64`) from [GitHub Releases](https://github.com/ejames-dev/NetDIFT/releases), then
61+
verify it:
62+
63+
```bash
64+
sha256sum -c SHA256SUMS.txt --ignore-missing
65+
tar -xzf netdift-v0.1.0-x86_64-unknown-linux-musl.tar.gz
66+
./netdift-v0.1.0-x86_64-unknown-linux-musl/netdift demo
67+
```
68+
69+
### Build from source
70+
5771
Requires **Rust (stable, Edition 2021)**.
5872

5973
```bash

0 commit comments

Comments
 (0)