Skip to content

Commit 6931bd4

Browse files
committed
feat: add NixOS packaging and automated release system
- Add flake.nix with dynamic version reading from Cargo.toml - Add GitHub Actions workflow for automated releases on git tags - Add RELEASING.md with cargo-release workflow documentation - Update README.md with NixOS-first installation instructions - Track Cargo.lock for reproducible builds - Add cargo-release configuration to Cargo.toml - Bump version to 0.4.0
1 parent 542fc3d commit 6931bd4

File tree

7 files changed

+6966
-15
lines changed

7 files changed

+6966
-15
lines changed

.github/workflows/release.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build-and-release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Rust toolchain
20+
uses: dtolnay/rust-toolchain@stable
21+
22+
- name: Cache cargo registry
23+
uses: actions/cache@v4
24+
with:
25+
path: ~/.cargo/registry
26+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
27+
28+
- name: Cache cargo index
29+
uses: actions/cache@v4
30+
with:
31+
path: ~/.cargo/git
32+
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
33+
34+
- name: Cache cargo build
35+
uses: actions/cache@v4
36+
with:
37+
path: target
38+
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
39+
40+
- name: Install Linux dependencies
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install -y \
44+
build-essential \
45+
portaudio19-dev \
46+
libclang-dev \
47+
pkg-config \
48+
libxkbcommon-dev \
49+
libwayland-dev \
50+
libx11-dev \
51+
libxcursor-dev \
52+
libxi-dev \
53+
libxrandr-dev \
54+
libasound2-dev \
55+
libssl-dev \
56+
libfftw3-dev \
57+
curl \
58+
cmake \
59+
libvulkan-dev \
60+
vulkan-headers \
61+
libopenblas-dev \
62+
shaderc
63+
64+
- name: Build release binary
65+
run: cargo build --release --verbose
66+
67+
- name: Run tests
68+
run: cargo test --release --verbose
69+
70+
- name: Extract version from tag
71+
id: get_version
72+
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
73+
74+
- name: Create release tarball
75+
run: |
76+
VERSION=${{ steps.get_version.outputs.VERSION }}
77+
ARCHIVE_NAME="sonori-${VERSION}-x86_64-linux"
78+
mkdir -p "${ARCHIVE_NAME}"
79+
cp target/release/sonori "${ARCHIVE_NAME}/"
80+
cp README.md LICENSE CONFIGURATION.md "${ARCHIVE_NAME}/"
81+
tar -czf "${ARCHIVE_NAME}.tar.gz" "${ARCHIVE_NAME}"
82+
echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> $GITHUB_ENV
83+
84+
- name: Generate release notes
85+
id: release_notes
86+
run: |
87+
VERSION=${{ steps.get_version.outputs.VERSION }}
88+
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
89+
echo "## Sonori v${VERSION}" >> $GITHUB_OUTPUT
90+
echo "" >> $GITHUB_OUTPUT
91+
echo "### Installation" >> $GITHUB_OUTPUT
92+
echo "" >> $GITHUB_OUTPUT
93+
echo "**NixOS (Recommended):**" >> $GITHUB_OUTPUT
94+
echo '```bash' >> $GITHUB_OUTPUT
95+
echo "nix run github:0xPD33/sonori" >> $GITHUB_OUTPUT
96+
echo "# or" >> $GITHUB_OUTPUT
97+
echo "nix profile install github:0xPD33/sonori" >> $GITHUB_OUTPUT
98+
echo '```' >> $GITHUB_OUTPUT
99+
echo "" >> $GITHUB_OUTPUT
100+
echo "**From Release Tarball:**" >> $GITHUB_OUTPUT
101+
echo "1. Download \`sonori-${VERSION}-x86_64-linux.tar.gz\`" >> $GITHUB_OUTPUT
102+
echo "2. Extract: \`tar -xzf sonori-${VERSION}-x86_64-linux.tar.gz\`" >> $GITHUB_OUTPUT
103+
echo "3. Run: \`./sonori-${VERSION}-x86_64-linux/sonori\`" >> $GITHUB_OUTPUT
104+
echo "" >> $GITHUB_OUTPUT
105+
echo "See README.md for building from source on other distributions." >> $GITHUB_OUTPUT
106+
echo "" >> $GITHUB_OUTPUT
107+
echo "### Changes" >> $GITHUB_OUTPUT
108+
echo "" >> $GITHUB_OUTPUT
109+
git log --pretty=format:"- %s" $(git describe --tags --abbrev=0 HEAD^)..HEAD >> $GITHUB_OUTPUT
110+
echo "EOF" >> $GITHUB_OUTPUT
111+
112+
- name: Create GitHub Release
113+
uses: softprops/action-gh-release@v1
114+
with:
115+
files: ${{ env.ARCHIVE_NAME }}.tar.gz
116+
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
117+
draft: false
118+
prerelease: false
119+
env:
120+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# rust
66
/target
77
**/*.rs.bk
8-
Cargo.lock
98
*.pdb
109

1110
# logs

0 commit comments

Comments
 (0)