Skip to content
Merged
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
32 changes: 15 additions & 17 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
project_name: comenq

plugins:
- import: github.com/goreleaser/goreleaser-rust@v1.6.0

builds:
- id: comenq
binary: comenq
main: ./crates/comenq
goos: [linux]
goarch: [amd64, arm64]
builder: go
hooks:
pre:
- cmd: cargo build --release --package comenq --target {{ .TARGET }}
- cmd: cp target/{{ .TARGET }}/release/comenq {{ .Path }}
builder: rust
targets:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- id: comenqd
binary: comenqd
main: ./crates/comenqd
goos: [linux]
goarch: [amd64, arm64]
builder: go
hooks:
pre:
- cmd: cargo build --release --package comenqd --target {{ .TARGET }}
- cmd: cp target/{{ .TARGET }}/release/comenqd {{ .Path }}
builder: rust
targets:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu

archives:
- id: default
Expand All @@ -29,7 +26,8 @@ archives:
files:
- LICENSE
- README.md
- packaging/comenqd/config.toml
- >-
packaging/config/comenqd.toml
Comment on lines +29 to +30
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify config path consistency across codebase.

The configuration path has been updated to packaging/config/comenqd.toml. Ensure all references throughout the codebase use the new path to prevent packaging inconsistencies.

Also applies to: 55-55


🏁 Script executed:

#!/bin/bash
# Search for any remaining references to the old config path
echo "Searching for old config path references:"
rg -n "packaging/comenqd/config\.toml" --type md --type yaml --type toml --type sh

echo -e "\nSearching for any hardcoded config paths:"
rg -n "config\.toml" --type md --type yaml --type toml --type sh | grep -v "packaging/config/comenqd.toml"

echo -e "\nVerifying systemd service file references:"
fd -e service -x cat {} \; | rg -n "config\.toml"

Length of output: 2633


Update config path references to use /etc/comenqd/config.toml consistently

Update all hard-coded paths and documentation to match the new comenqd directory name:

• .goreleaser.yaml (line 56): change
dst: /etc/comenq/config.tomldst: /etc/comenqd/config.toml
• Systemd service files: replace --config /etc/comenq/config.toml--config /etc/comenqd/config.toml
• docs/roadmap.md (line 34): ensure path reads /etc/comenqd/config.toml
• docs/automated-cross-platform-packaging.md: replace every /etc/comenq/config.toml, usr/local/etc/comenq/config.toml, etc/"comenq/config.toml" with /etc/comenqd/config.toml, usr/local/etc/comenqd/config.toml, etc/"comenqd/config.toml"
• docs/comenq-design.md (lines 506, 517, 596, 625, 687, 690–692, 909): update all /etc/comenqd/config.toml references to match the new filename if any still use the old spelling

Fix these to prevent inconsistencies during packaging and installation.

🤖 Prompt for AI Agents
In .goreleaser.yaml around lines 29 to 30 and specifically at line 56, update
the destination path from /etc/comenq/config.toml to /etc/comenqd/config.toml to
reflect the new directory name. Also, review and update all related systemd
service files, documentation files including docs/roadmap.md at line 34,
docs/automated-cross-platform-packaging.md, and docs/comenq-design.md at the
specified lines to replace any old path references with the consistent
/etc/comenqd/config.toml path. This ensures all references to the config path
are uniform and correct.


nfpms:
- id: comenq-packages
Expand All @@ -54,8 +52,8 @@ nfpms:
contents:
- src: packaging/linux/comenqd.service
dst: /lib/systemd/system/comenqd.service
- src: packaging/comenqd/config.toml
dst: /etc/comenq/config.toml
- src: packaging/config/comenqd.toml
dst: /etc/comenqd/config.toml
type: config
scripts:
preinstall: packaging/linux/preinstall.sh
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ path = "src/lib.rs"

[dependencies]
serde = { workspace = true }
serde_yaml = { workspace = true }
serde_json = { workspace = true }

[dev-dependencies]
Expand All @@ -23,6 +22,7 @@ yaque = { workspace = true }
wiremock = { workspace = true }
octocrab = { workspace = true }
test-support = { path = "test-support" }
serde_yaml = { workspace = true }
regex = { workspace = true }

[[test]]
Expand Down
186 changes: 35 additions & 151 deletions docs/automated-cross-platform-packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ Group=comenq

# The command to start the daemon
# Assumes the binary is installed to /usr/bin/comenqd
# The configuration file is expected at /etc/comenq/config.toml
ExecStart=/usr/bin/comenqd --config /etc/comenq/config.toml
# The configuration file is expected at /etc/comenqd/config.toml
ExecStart=/usr/bin/comenqd --config /etc/comenqd/config.toml

# Security Hardening
# Disallow any privileges
Expand Down Expand Up @@ -71,13 +71,13 @@ WantedBy=multi-user.target
```

**Note:** This unit file assumes a configuration file at
`/etc/comenq/config.toml`. You should provide a default configuration file with
your package.
`/etc/comenqd/config.toml`. A default configuration file must ship with the
package.

#### Step 2: Create a Default Configuration File

Create a default `config.toml` file to be included in the packages. Place it at
`packaging/comenqd/config.toml`.
`packaging/config/comenqd.toml`.

```toml
# Default configuration for comenqd
Expand All @@ -88,120 +88,7 @@ Create a default `config.toml` file to be included in the packages. Place it at
# cooldown_period_seconds = 960
```

#### Step 3: Create the `.goreleaser.yaml` Configuration

Now, create the main GoReleaser configuration file in the root of your
repository. This file defines the entire release process.

#### `.goreleaser.yaml`

```yaml
# .goreleaser.yaml
# Visit https://goreleaser.com/customization/ for more options
project_name: comenq

# This section is only needed if you use the GoReleaser Go proxy
# to build. Since we are building a Rust project, we will override
# the build step entirely.
builds:
- id: comenq
binary: comenq
main: ./crates/comenq
goos: [linux, darwin]
goarch: [amd64, arm64]
# We use a custom build command with Cargo
builder: go
hooks:
pre:
- cmd: cargo build --release --package comenq --target {{ .TARGET }}
- cmd: cp target/{{ .TARGET }}/release/comenq {{ .Path }}
- id: comenqd
binary: comenqd
main: ./crates/comenqd
goos: [linux, darwin]
goarch: [amd64, arm64]
# We use a custom build command with Cargo
builder: go
hooks:
pre:
- cmd: cargo build --release --package comenqd --target {{ .TARGET }}
- cmd: cp target/{{ .TARGET }}/release/comenqd {{ .Path }}

# Create archives of the binaries.
archives:
- id: default
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
format: tar.gz
files:
- LICENSE
- README.md

# Configuration for creating Linux packages (.deb and .rpm)
nfpms:
- id: comenq-packages
package_name: comenq
vendor: "Your Name"
homepage: "https://github.com/leynos/comenq"
maintainer: "Your Name <your.email@example.com>"
description: "Client for the Comenq notification system."
license: MIT
formats:
- deb
- rpm
# Target only the 'comenq' build
builds:
- comenq

- id: comenqd-packages
package_name: comenqd
vendor: "Your Name"
homepage: "https://github.com/leynos/comenq"
maintainer: "Your Name <your.email@example.com>"
description: "Daemon for the Comenq notification system."
license: MIT
formats:
- deb
- rpm
# Target only the 'comenqd' build
builds:
- comenqd
# Files to include in the package
contents:
# The systemd unit file
- src: packaging/linux/comenqd.service
dst: /lib/systemd/system/comenqd.service
# The default configuration file
- src: packaging/comenqd/config.toml
dst: /etc/comenq/config.toml
type: config
# Scripts to run on installation
scripts:
preinstall: "packaging/linux/preinstall.sh"
postinstall: "packaging/linux/postinstall.sh"
preremove: "packaging/linux/preremove.sh"

# Create a GitHub release
release:
github:
owner: leynos
name: comenq
draft: true # Set to false to auto-publish

# Generate a changelog from commit messages
changelog:
sort: asc
filters:
# Exclude chore, style, and test commits from the changelog
exclude:
- '^docs:'
- '^test:'
- '^chore:'
- '^style:'
- 'Merge pull request'
- 'Merge branch'
```

#### Step 4: Create Installation Scripts
#### Step 3: Create Installation Scripts

The `systemd` unit file requires a dedicated user. These scripts will create
the `comenq` user and group upon installation.
Expand Down Expand Up @@ -250,7 +137,7 @@ fi

Make these scripts executable: `chmod +x packaging/linux/*.sh`.

#### Step 5: Update the GitHub Actions Workflow
#### Step 4: Update the GitHub Actions Workflow

Finally, modify your existing `.github/workflows/release.yml` to use
GoReleaser. This workflow will trigger when you push a new tag (e.g., `v1.2.3`).
Expand Down Expand Up @@ -319,7 +206,7 @@ Create `packaging/darwin/comenqd.plist`:
<array>
<string>/usr/local/bin/comenqd</string>
<string>--config</string>
<string>/usr/local/etc/comenq/config.toml</string>
<string>/usr/local/etc/comenqd/config.toml</string>
</array>
<key>RunAtLoad</key>
<true/>
Expand Down Expand Up @@ -383,7 +270,7 @@ brews:

# The service block for `comenqd`
service: |
run [opt_bin/"comenqd", "--config", etc/"comenq/config.toml"]
run [opt_bin/"comenqd", "--config", etc/"comenqd/config.toml"]
keep_alive true
log_path var/"log/comenq/comenqd.log"
error_log_path var/"log/comenq/comenqd.err"
Expand All @@ -392,20 +279,16 @@ brews:
install: |
bin.install "comenq"
bin.install "comenqd"
(etc/"comenq").mkpath
etc.install "config.toml" => "comenq/config.toml"
(etc/"comenqd").mkpath
etc.install "config.toml" => "comenqd/config.toml"
(var/"log/comenq").mkpath
Comment on lines +282 to 284
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix missing configuration file in Homebrew formula

etc.install "config.toml" assumes the file sits at the archive root, but
the archive currently stores it under packaging/config/comenqd.toml
(Line 332). brew will fail to locate the file, breaking macOS installs.

Patch either archive or formula so both sides agree:

# Option A (preferred): expose the config at archive root
 archives:
   files:
     - LICENSE
     - README.md
-    - packaging/config/comenqd.toml
+    - src: packaging/config/comenqd.toml
+      dst: config.toml

# Option B: keep directory structure and reference it correctly in the formula
-      etc.install "config.toml" => "comenqd/config.toml"
+      etc.install "packaging/config/comenqd.toml" => "comenqd/config.toml"

Choose one approach and keep the pathing consistent throughout.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In docs/automated-cross-platform-packaging.md around lines 282 to 284, the
Homebrew formula incorrectly assumes the config.toml file is at the archive
root, but it is actually located under packaging/config/comenqd.toml. To fix
this, update the formula's etc.install path to match the archive location or
move the config file in the archive to the root so both paths align. Ensure the
path used in the formula and the archive is consistent to prevent brew install
failures on macOS.

```

#### Step 3: Add the macOS Configuration File

The Homebrew formula will also install a default configuration. Add a copy for
macOS, perhaps identical to the Linux one, at `packaging/darwin/config.toml`.
Update the `brews.contents` section in `.goreleaser.yaml` to point to it if it
differs, or simply add it to the `files` section of the archive if it's
universal. For simplicity, let's assume the one at
`packaging/comenqd/config.toml` is sufficient and will be picked up by the
archive.
The Homebrew formula will also install a default configuration. Since the same
settings apply on both platforms, the shared `packaging/config/comenqd.toml` is
sufficient and will be picked up by the archive.

#### Step 4: Final `.goreleaser.yaml`

Expand All @@ -416,27 +299,28 @@ configurations:
# .goreleaser.yaml
project_name: comenq

plugins:
- import: github.com/goreleaser/goreleaser-rust@v1.6.0

builds:
- id: comenq
binary: comenq
main: ./crates/comenq
goos: [linux, darwin]
goarch: [amd64, arm64]
builder: go
hooks:
pre:
- cmd: cargo build --release --package comenq --target {{ .TARGET }}
- cmd: cp target/{{ .TARGET }}/release/comenq {{ .Path }}
builder: rust
targets:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin
- id: comenqd
binary: comenqd
main: ./crates/comenqd
goos: [linux, darwin]
goarch: [amd64, arm64]
builder: go
hooks:
pre:
- cmd: cargo build --release --package comenqd --target {{ .TARGET }}
- cmd: cp target/{{ .TARGET }}/release/comenqd {{ .Path }}
builder: rust
targets:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin

archives:
- id: default
Expand All @@ -445,7 +329,7 @@ archives:
files:
- LICENSE
- README.md
- packaging/comenqd/config.toml
- packaging/config/comenqd.toml

Comment thread
leynos marked this conversation as resolved.
nfpms:
- id: comenq-packages
Expand All @@ -470,8 +354,8 @@ nfpms:
contents:
- src: packaging/linux/comenqd.service
dst: /lib/systemd/system/comenqd.service
- src: packaging/comenqd/config.toml
dst: /etc/comenq/config.toml
- src: packaging/config/comenqd.toml
dst: /etc/comenqd/config.toml
type: config
scripts:
preinstall: "packaging/linux/preinstall.sh"
Expand All @@ -492,15 +376,15 @@ brews:
license: "MIT"
builds: [comenq, comenqd]
service: |
run [opt_bin/"comenqd", "--config", etc/"comenq/config.toml"]
run [opt_bin/"comenqd", "--config", etc/"comenqd/config.toml"]
keep_alive true
log_path var/"log/comenq/comenqd.log"
error_log_path var/"log/comenq/comenqd.err"
install: |
bin.install "comenq"
bin.install "comenqd"
(etc/"comenq").mkpath
etc.install "config.toml" => "comenq/config.toml"
(etc/"comenqd").mkpath
etc.install "config.toml" => "comenqd/config.toml"
(var/"log/comenq").mkpath

release:
Expand Down
15 changes: 8 additions & 7 deletions docs/comenq-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -717,13 +717,14 @@ service.
### 4.4. Packaging and Release Workflow

To simplify installation, the project uses GoReleaser. The declarative
`.goreleaser.yaml` invokes `cargo build` for both binaries via custom pre-build
hooks. The `nfpms` section produces signed `.deb` and `.rpm` packages for
Fedora and Ubuntu, embedding the hardened `systemd` service unit and lifecycle
scripts that create the `comenq` user. This keeps packaging logic version
controlled and repeatable. A GitHub Actions workflow triggers on version tags
to run GoReleaser. It builds Linux packages and uploads them to a draft
release. Mac support is currently deferred, so the workflow targets Linux only.
`.goreleaser.yaml` builds both binaries via the `goreleaser-rust` plugin,
eliminating manual pre-build hooks. The `nfpms` section produces signed `.deb`
and `.rpm` packages for Fedora and Ubuntu, embedding the hardened `systemd`
service unit and lifecycle scripts that create the `comenq` user. This keeps
packaging logic version controlled and repeatable. A GitHub Actions workflow
triggers on version tags to run GoReleaser. It builds Linux packages and
uploads them to a draft release. Mac support is currently deferred, so the
workflow targets Linux only.
Comment thread
leynos marked this conversation as resolved.

## Section 5: Complete Source Code and Project Manifest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Default configuration for comenqd

# GitHub Personal Access Token used for authentication
# GitHub Personal Access Token used for authentication.
# If left empty, GitHub integration is disabled.
# github_token = ""

# Minimum log level to output
Expand Down
Loading
Loading