Skip to content

Commit

Permalink
add release workflow with per-platform archives
Browse files Browse the repository at this point in the history
build.zig: extract install-demo step for CI use
build.zig.zon: add minimum_zig_version and crdt-demo to paths
crdt-lib/build.zig.zon: sync version to 0.1.0, fix paths
  • Loading branch information
pyotrk committed May 26, 2026
1 parent d7f9ec8 commit e74a2a7
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 4 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: CI
on:
push:
branches: [master]
tags: ['v*']
pull_request:
branches: [master]

Expand Down Expand Up @@ -86,6 +87,23 @@ jobs:
path: zig-out/bin/crdt-server
if-no-files-found: error

build-demo:
runs-on: ntnu-runners
steps:
- uses: actions/checkout@v4

- uses: mlugg/setup-zig@v2
with:
version: 0.16.0

- run: zig build install-demo

- uses: actions/upload-artifact@v3
with:
name: crdt-demo
path: zig-out/www/
if-no-files-found: error

build-docs:
runs-on: ntnu-runners
steps:
Expand Down Expand Up @@ -121,3 +139,60 @@ jobs:
steps:
- uses: actions/deploy-pages@v3
id: deployment

release:
if: startsWith(github.ref, 'refs/tags/')
needs: [build-linux, build-windows, build-macos, build-demo]
runs-on: ntnu-runners
permissions:
contents: write
steps:
- uses: actions/download-artifact@v3
with:
name: crdt-server-linux
path: dist/linux
- uses: actions/download-artifact@v3
with:
name: crdt-server-windows
path: dist/windows
- uses: actions/download-artifact@v3
with:
name: crdt-server-macos-x86_64
path: dist/macos-x86_64
- uses: actions/download-artifact@v3
with:
name: crdt-server-macos-aarch64
path: dist/macos-aarch64
- uses: actions/download-artifact@v3
with:
name: crdt-demo
path: dist/demo

- run: mkdir -p package/linux/bin
- run: cp dist/linux/crdt-server package/linux/bin/
- run: tar czf crdt-${{ github.ref_name }}-linux-x86_64.tar.gz -C package/linux bin/

- run: mkdir -p package/windows/bin
- run: cp dist/windows/crdt-server.exe package/windows/bin/
- run: (cd package/windows && zip -r ../../crdt-${{ github.ref_name }}-windows-x86_64.zip bin/)

- run: mkdir -p package/macos-x86_64/bin
- run: cp dist/macos-x86_64/crdt-server package/macos-x86_64/bin/
- run: tar czf crdt-${{ github.ref_name }}-macos-x86_64.tar.gz -C package/macos-x86_64 bin/

- run: mkdir -p package/macos-aarch64/bin
- run: cp dist/macos-aarch64/crdt-server package/macos-aarch64/bin/
- run: tar czf crdt-${{ github.ref_name }}-macos-aarch64.tar.gz -C package/macos-aarch64 bin/

- run: mkdir -p package/demo/www
- run: cp dist/demo/* package/demo/www/
- run: tar czf crdt-${{ github.ref_name }}-demo.tar.gz -C package/demo www/

- uses: softprops/action-gh-release@v2
with:
files: |
crdt-${{ github.ref_name }}-linux-x86_64.tar.gz
crdt-${{ github.ref_name }}-windows-x86_64.zip
crdt-${{ github.ref_name }}-macos-x86_64.tar.gz
crdt-${{ github.ref_name }}-macos-aarch64.tar.gz
crdt-${{ github.ref_name }}-demo.tar.gz
7 changes: 5 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ pub fn build(b: *std.Build) !void {
docs_step.dependOn(&lib_docs_install.step);
docs_step.dependOn(&server_docs_install.step);

const install_demo_step = b.step("install-demo", "builds and installs the WASM demo");
install_demo_step.dependOn(&install_demo_wasm.step);
install_demo_step.dependOn(&install_demo_static.step);

const install_step = b.getInstallStep();
install_step.dependOn(&install_demo_wasm.step);
install_step.dependOn(&install_demo_static.step);
install_step.dependOn(install_demo_step);
b.installArtifact(server_exe);
}
2 changes: 2 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
.{
.name = .crdt,
.version = "0.1.0",
.minimum_zig_version = "0.16.0",
.dependencies = .{
.crdt_lib = .{ .path = "crdt-lib" },
},
.paths = .{
"build.zig",
"build.zig.zon",
"crdt-demo",
"crdt-lib",
"crdt-server",
},
Expand Down
2 changes: 2 additions & 0 deletions crdt-lib/build.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Build script that re-exports the lib as a module.
//! Needed in case I want to create a separate repo for the lib.
const std = @import("std");

pub fn build(b: *std.Build) void {
Expand Down
8 changes: 6 additions & 2 deletions crdt-lib/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.{
.name = .crdt_lib,
.version = "0.0.1",
.version = "0.1.0",
.minimum_zig_version = "0.16.0",
.paths = .{""},
.paths = .{
"build.zig",
"build.zig.zon",
"src",
},
.fingerprint = 0x1aa64f5a01e5a904,
}

0 comments on commit e74a2a7

Please sign in to comment.