From ca5f12610e668c50621b4ed779f441629a352cce Mon Sep 17 00:00:00 2001 From: Artie Poole Date: Tue, 10 Mar 2026 16:13:56 +0000 Subject: [PATCH 1/4] root: prepare for package publishing Signed-off-by: Artie Poole --- Cargo.lock | 50 +++++++++++++-------------- Cargo.toml | 9 +++++ PUBLISHING.md | 75 +++++++++++++++++++++++++++++++++++++++++ cli/Cargo.toml | 18 ++++++++-- daemon/Cargo.toml | 17 ++++++---- fpgad_macros/Cargo.toml | 12 +++++-- 6 files changed, 144 insertions(+), 37 deletions(-) create mode 100644 PUBLISHING.md diff --git a/Cargo.lock b/Cargo.lock index 8d9e207f..e344796c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -165,17 +165,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" -[[package]] -name = "cli" -version = "0.1.0" -dependencies = [ - "clap", - "env_logger", - "log", - "tokio", - "zbus", -] - [[package]] name = "colorchoice" version = "1.0.4" @@ -197,20 +186,6 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" -[[package]] -name = "daemon" -version = "0.1.0" -dependencies = [ - "env_logger", - "fpgad_macros", - "googletest", - "log", - "rstest", - "thiserror", - "tokio", - "zbus", -] - [[package]] name = "endi" version = "1.1.0" @@ -304,6 +279,31 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +[[package]] +name = "fpgad" +version = "0.1.0" +dependencies = [ + "env_logger", + "fpgad_macros", + "googletest", + "log", + "rstest", + "thiserror", + "tokio", + "zbus", +] + +[[package]] +name = "fpgad_cli" +version = "0.1.0" +dependencies = [ + "clap", + "env_logger", + "log", + "tokio", + "zbus", +] + [[package]] name = "fpgad_macros" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index f7fb30d1..1e2b0c2f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,12 @@ [workspace] resolver = "3" members = ["daemon", "cli", "fpgad_macros"] + +[workspace.package] +version = "0.1.0" +edition = "2024" +license = "GPL-3.0" +homepage = "https://github.com/canonical/fpgad" +repository = "https://github.com/canonical/fpgad" +authors = ["Talha Can Havadar ", "Artie Poole "] + diff --git a/PUBLISHING.md b/PUBLISHING.md new file mode 100644 index 00000000..f5d1bb32 --- /dev/null +++ b/PUBLISHING.md @@ -0,0 +1,75 @@ +# Publishing Guide for FPGAd + +This document explains how to publish the FPGAd packages to crates.io. + +## Package Structure + +The workspace contains 3 packages: + +1. **`fpgad_macros`** - Procedural macros (must be published first) +2. **`fpgad`** - The daemon (depends on fpgad_macros) +3. **`fpgad_cli`** - Command-line interface + +## Publication Order + +Packages must be published in this order due to dependencies: + +1. `fpgad_macros` (no dependencies on other workspace crates) +2. `fpgad` (depends on fpgad_macros) +3. `fpgad_cli` (no dependencies on other workspace crates, but logically depends on daemon) + +## Pre-publication Checklist + +- [x] All packages have proper metadata (version, license, description, etc.) +- [x] All packages have README.md files +- [x] Workspace-level metadata is shared across packages +- [x] Dependencies have version requirements specified +- [x] All packages compile successfully +- [x] All tests pass (CI auto runs on PR) +- [x] Documentation is complete +- [x] CHANGELOG is up to date +- [x] Git repository is clean + +## Publishing Commands + +### 1. Publish fpgad_macros + +```bash +cd fpgad_macros +cargo publish +``` + +### 2. Publish fpgad + +```bash +cd daemon +cargo publish +``` + +### 3. Publish fpgad_cli + +```bash +cd cli +cargo publish +``` + +## Dry Run Testing + +Before publishing, test with dry-run: + +```bash +cargo publish --dry-run +``` + +## Version Updates + +When releasing new versions, update the version in the workspace `Cargo.toml`: + +```toml +[workspace.package] +version = "0.2.0" # Update this +``` + +All packages will inherit this version. + +Note that the CI pipeline will enforce an increase in the version whenever contents of a .rs file inside /src is changed, before the commits can be merged. diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 0477d28d..89b2b151 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,7 +1,19 @@ [package] -name = "cli" -version = "0.1.0" -edition = "2024" +name = "fpgad_cli" +version.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true +authors.workspace = true +description = "Command-line interface for interacting with the FPGAd daemon" +readme = "README.md" +keywords = ["fpga", "cli", "embedded", "hardware", "xilinx"] +categories = ["command-line-utilities", "hardware-support"] + +[[bin]] +name = "fpgad_cli" +path = "src/main.rs" [dependencies] clap = { version = "4.5.41", features = ["derive"] } diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index d9132b3e..7158b553 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -1,12 +1,15 @@ [package] -name = "daemon" -version = "0.1.0" -edition = "2024" -license = "GPL-3.0" +name = "fpgad" +version.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true +authors.workspace = true description = "An FPGA manager daemon that handles the dirty work for you." -homepage = "https://github.com/talhaHavadar/fpgad" -repository = "https://github.com/talhaHavadar/fpgad" readme = "README.md" +keywords = ["fpga", "daemon", "embedded", "hardware", "xilinx"] +categories = ["hardware-support", "embedded"] [features] default = ["softeners-all"] @@ -15,7 +18,7 @@ softeners = [] xilinx-dfx-mgr = ["softeners"] [dependencies] -fpgad_macros = { path = "../fpgad_macros" } +fpgad_macros = { version = "0.1.0", path = "../fpgad_macros" } log = "0.4.27" env_logger = "0.11.8" tokio = { version = "1.47.0", features = ["full"] } diff --git a/fpgad_macros/Cargo.toml b/fpgad_macros/Cargo.toml index 79a94b83..a08635c5 100644 --- a/fpgad_macros/Cargo.toml +++ b/fpgad_macros/Cargo.toml @@ -1,7 +1,15 @@ [package] name = "fpgad_macros" -version = "0.1.0" -edition = "2024" +version.workspace = true +edition.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true +authors.workspace = true +description = "Procedural macros for the FPGAd project" +readme = "README.md" +keywords = ["fpga", "macros", "proc-macro"] +categories = ["development-tools::procedural-macro-helpers"] [lib] proc-macro = true From a033a9edaaeab4119340e15ef4f8415228ce5ef7 Mon Sep 17 00:00:00 2001 From: Artie Poole Date: Thu, 26 Mar 2026 14:52:15 +0000 Subject: [PATCH 2/4] snapcraft: rename binaries to match cargo crate names for publishing Signed-off-by: Artie Poole --- .git_components.yaml | 3 +++ snap/snapcraft.yaml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.git_components.yaml b/.git_components.yaml index b6e584d4..cfc5dbc2 100644 --- a/.git_components.yaml +++ b/.git_components.yaml @@ -37,3 +37,6 @@ config: tests: owners: - artiepoole +snapcraft: + owners: + - artiepoole diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index cb179d06..5cb6d80e 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -47,11 +47,11 @@ plugs: - /sys/kernel/config/device-tree/overlays apps: fpgad: - command: bin/cli + command: bin/fpgad_cli plugs: - cli-dbus daemon: - command: bin/daemon + command: bin/fpgad daemon: dbus restart-condition: always start-timeout: 30s From 12d8e56524ab14224cf0d45232cebd5a82bcf4e0 Mon Sep 17 00:00:00 2001 From: Artie Poole Date: Tue, 10 Mar 2026 16:19:37 +0000 Subject: [PATCH 3/4] workflows: add linter to enforce version bump on change to source files Signed-off-by: Artie Poole --- .github/workflows/linter.yml | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index c0441731..b7d2e320 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -144,6 +144,93 @@ jobs: echo "::group::yamlfmt output" yamlfmt -lint . echo "::endgroup::" + version-bump-check: + name: Check Version Bump for Rust Changes + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Check if version was bumped + run: | + echo "::group::check for modified Rust source files" + # Check if any .rs files in /src/ directories have been modified + changed_rust_files=$(git diff --name-only --diff-filter=ACMRTUXB origin/${{ github.base_ref }} | grep -E "^(daemon|cli|fpgad_macros)/src/.*\.rs$" || true) + + if [ -z "$changed_rust_files" ]; then + echo "✅ No Rust source files modified - version bump not required." + exit 0 + fi + + echo "Modified Rust source files detected:" + echo "$changed_rust_files" + echo "::endgroup::" + + echo "::group::extract version numbers" + # Get the old version from base branch + git show origin/${{ github.base_ref }}:Cargo.toml > /tmp/base_cargo.toml + old_version=$(grep -A 10 '^\[workspace.package\]' /tmp/base_cargo.toml | grep '^version' | head -1 | sed -E 's/version[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/') + + # Get the new version from current branch + new_version=$(grep -A 10 '^\[workspace.package\]' Cargo.toml | grep '^version' | head -1 | sed -E 's/version[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/') + + if [ -z "$old_version" ]; then + echo "::error::Could not extract old version from base branch Cargo.toml" + exit 1 + fi + + if [ -z "$new_version" ]; then + echo "::error::Could not extract new version from current Cargo.toml" + exit 1 + fi + + echo "Old version: $old_version" + echo "New version: $new_version" + echo "::endgroup::" + + echo "::group::compare versions using semver" + # Parse semver components (major.minor.patch[-prerelease][+build]) + parse_version() { + local version=$1 + # Extract major.minor.patch (ignore pre-release and build metadata for now) + local base_version=$(echo "$version" | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/') + echo "$base_version" + } + + old_base=$(parse_version "$old_version") + new_base=$(parse_version "$new_version") + + # Split into components + IFS='.' read -r old_major old_minor old_patch <<< "$old_base" + IFS='.' read -r new_major new_minor new_patch <<< "$new_base" + + # Compare versions + version_increased=false + + if [ "$new_major" -gt "$old_major" ]; then + version_increased=true + elif [ "$new_major" -eq "$old_major" ] && [ "$new_minor" -gt "$old_minor" ]; then + version_increased=true + elif [ "$new_major" -eq "$old_major" ] && [ "$new_minor" -eq "$old_minor" ] && [ "$new_patch" -gt "$old_patch" ]; then + version_increased=true + fi + + if [ "$version_increased" = false ]; then + echo "::error::Version was not increased!%0A\ + Old version: $old_version%0A\ + New version: $new_version%0A\ + %0A\ + Rust source files were modified but the version was not bumped in Cargo.toml.%0A\ + Please update the version in the [workspace.package] section of the root Cargo.toml.%0A\ + Version must follow semver and be greater than $old_version.%0A\ + %0A\ + Modified Rust files:%0A\ + $(echo "$changed_rust_files" | sed 's/^/- /' | tr '\n' '|' | sed 's/|/%0A/g')" + exit 1 + else + echo "✅ Version was properly increased: $old_version → $new_version" + echo "::endgroup::" + fi rust-check: name: Check Rust Code runs-on: ubuntu-latest From 7cca017cf7e13fc8f23ff00bb7dc9f13fb86c420 Mon Sep 17 00:00:00 2001 From: Artie Poole Date: Thu, 26 Mar 2026 14:09:46 +0000 Subject: [PATCH 4/4] root: fix cargo dependency such that fpgad_macros is found from cargo unless locally present Signed-off-by: Artie Poole --- Cargo.toml | 3 +++ daemon/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1e2b0c2f..988ea15d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,6 @@ homepage = "https://github.com/canonical/fpgad" repository = "https://github.com/canonical/fpgad" authors = ["Talha Can Havadar ", "Artie Poole "] +[workspace.dependencies] +fpgad_macros = { version = "0.1.0", path = "fpgad_macros" } + diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index 7158b553..6f243f3d 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -18,7 +18,7 @@ softeners = [] xilinx-dfx-mgr = ["softeners"] [dependencies] -fpgad_macros = { version = "0.1.0", path = "../fpgad_macros" } +fpgad_macros = { workspace = true } log = "0.4.27" env_logger = "0.11.8" tokio = { version = "1.47.0", features = ["full"] }