Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git_components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ config:
tests:
owners:
- artiepoole
snapcraft:
owners:
- artiepoole
87 changes: 87 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <package>/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
Expand Down
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
[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 <talha.can.havadar@canonical.com>", "Artie Poole <stuart.poole@canonical.com>"]

[workspace.dependencies]
fpgad_macros = { version = "0.1.0", path = "fpgad_macros" }

75 changes: 75 additions & 0 deletions PUBLISHING.md
Original file line number Diff line number Diff line change
@@ -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 <part>/src is changed, before the commits can be merged.
18 changes: 15 additions & 3 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"] }
Expand Down
17 changes: 10 additions & 7 deletions daemon/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -15,7 +18,7 @@ softeners = []
xilinx-dfx-mgr = ["softeners"]

[dependencies]
fpgad_macros = { path = "../fpgad_macros" }
fpgad_macros = { workspace = true }
log = "0.4.27"
env_logger = "0.11.8"
tokio = { version = "1.47.0", features = ["full"] }
Expand Down
12 changes: 10 additions & 2 deletions fpgad_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading