From 66d7443e26a45e2b7439e5b0ae8be90ea313717a Mon Sep 17 00:00:00 2001 From: Marcus Johansson Date: Wed, 16 Sep 2026 20:37:08 +0200 Subject: [PATCH 1/2] Build Debian packages in CI Add a goreleaser nfpms section producing amd64/arm64/386 .debs, so tagged releases publish them alongside the archives. The test workflow now runs a snapshot release and uploads the packages as artifacts. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/test.yml | 11 +++++++++-- .gitignore | 2 ++ .goreleaser.yml | 31 +++++++++++++++++++++++++++++++ CLAUDE.md | 4 +++- README.md | 15 +++++++++++++++ packaging/fwatch.service | 24 ++++++++++++++++++++++++ 6 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 packaging/fwatch.service diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 87800f8..18a46b3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,11 +48,18 @@ jobs: with: go-version: '1.25' - - name: Run GoReleaser (build-only) + - name: Run GoReleaser (snapshot, builds .deb packages) uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser version: '~> v2' - args: build --snapshot --clean + args: release --snapshot --clean --skip=publish,announce env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Debian packages + uses: actions/upload-artifact@v4 + with: + name: debian-packages + path: dist/*.deb + if-no-files-found: error diff --git a/.gitignore b/.gitignore index b8057d4..ba6f1ae 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ config.yaml # Logs *.log +# GoReleaser output +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml index 59e9940..1e2bf8c 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -34,6 +34,32 @@ archives: - config.example.yaml - fwatch.service +nfpms: + - id: fwatch + ids: + - fwatch + package_name: fwatch + vendor: polarn + homepage: "https://github.com/polarn/fwatch" + maintainer: "Marcus Johansson " + description: "A lightweight, configurable file organizer that automatically moves files based on their extensions" + license: "Apache-2.0" + formats: + - deb + bindir: /usr/bin + section: utils + file_name_template: >- + {{ .ProjectName }}_{{ .Version }}_{{ .Arch }} + contents: + - src: ./packaging/fwatch.service + dst: /usr/lib/systemd/user/fwatch.service + - src: ./config.example.yaml + dst: /usr/share/doc/fwatch/config.example.yaml + - src: ./README.md + dst: /usr/share/doc/fwatch/README.md + - src: ./LICENSE + dst: /usr/share/doc/fwatch/LICENSE + snapshot: version_template: "{{ incpatch .Version }}-next" @@ -59,6 +85,11 @@ release: yay -S fwatch-bin ``` + **Debian/Ubuntu:** + ```bash + sudo dpkg -i fwatch_{{ trimprefix .Tag "v" }}_amd64.deb + ``` + **Manual Installation:** Download the appropriate binary for your platform below. diff --git a/CLAUDE.md b/CLAUDE.md index 91a0229..7d35ca0 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,7 +10,9 @@ destination directories by extension. All logic lives in `main.go`. - `config.example.yaml` — reference config. Real config is `$XDG_CONFIG_HOME/fwatch/config.yaml`, else `~/.config/fwatch/config.yaml`. - `fwatch.service` — example systemd **user** unit (ExecStart `/usr/local/bin/fwatch`). -- `.goreleaser.yml` — builds, archives, AUR (`fwatch-bin`) publishing. +- `packaging/fwatch.service` — the unit shipped in the `.deb` (ExecStart `/usr/bin/fwatch`); + keep it in sync with the root one, which targets source installs. +- `.goreleaser.yml` — builds, archives, `.deb` packages (nfpms), AUR (`fwatch-bin`) publishing. - `.github/workflows/` — `test.yml` (vet/test/build on PRs and main), `release.yml` (goreleaser, triggered by `X.Y.Z` tags). diff --git a/README.md b/README.md index 2a5a06e..d1e763c 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,21 @@ yay -S fwatch-bin paru -S fwatch-bin ``` +### Debian / Ubuntu + +Download the `.deb` for your architecture from the [releases page](https://github.com/polarn/fwatch/releases) and install it: + +```bash +sudo dpkg -i fwatch_*_amd64.deb +``` + +The package installs the binary to `/usr/bin/fwatch` and a systemd **user** unit to +`/usr/lib/systemd/user/fwatch.service`, so after configuring fwatch you can run: + +```bash +systemctl --user enable --now fwatch.service +``` + ### Pre-built Binaries Download the latest release for your platform from the [releases page](https://github.com/polarn/fwatch/releases). diff --git a/packaging/fwatch.service b/packaging/fwatch.service new file mode 100644 index 0000000..901aee4 --- /dev/null +++ b/packaging/fwatch.service @@ -0,0 +1,24 @@ +[Unit] +Description=fwatch - Automatic file organizer +Documentation=https://github.com/polarn/fwatch +After=network.target + +[Service] +Type=simple +# Path used by the Debian package (the binary lands in /usr/bin) +ExecStart=/usr/bin/fwatch + +# Restart policy +Restart=always +RestartSec=10 + +# Security hardening +NoNewPrivileges=true +PrivateTmp=true + +# Logging +StandardOutput=journal +StandardError=journal + +[Install] +WantedBy=default.target From 8405d3286a1ee53d259ff716026a00b855f56020 Mon Sep 17 00:00:00 2001 From: Marcus Johansson Date: Wed, 16 Sep 2026 20:50:17 +0200 Subject: [PATCH 2/2] Use a single systemd unit file The unit now lives only at the repo root with ExecStart=/usr/bin/fwatch, the path both the deb and the AUR package install the binary to. Previously the AUR package shipped a unit pointing at /usr/local/bin, which never matched. Co-Authored-By: Claude Opus 5 (1M context) --- .goreleaser.yml | 2 +- CLAUDE.md | 6 +++--- README.md | 3 +++ fwatch.service | 5 +++-- packaging/fwatch.service | 24 ------------------------ 5 files changed, 10 insertions(+), 30 deletions(-) delete mode 100644 packaging/fwatch.service diff --git a/.goreleaser.yml b/.goreleaser.yml index 1e2bf8c..31c3cff 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -51,7 +51,7 @@ nfpms: file_name_template: >- {{ .ProjectName }}_{{ .Version }}_{{ .Arch }} contents: - - src: ./packaging/fwatch.service + - src: ./fwatch.service dst: /usr/lib/systemd/user/fwatch.service - src: ./config.example.yaml dst: /usr/share/doc/fwatch/config.example.yaml diff --git a/CLAUDE.md b/CLAUDE.md index 7d35ca0..e46f1a7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -9,9 +9,9 @@ destination directories by extension. All logic lives in `main.go`. `moveFile` falls back to copy+delete on cross-device rename failures. - `config.example.yaml` — reference config. Real config is `$XDG_CONFIG_HOME/fwatch/config.yaml`, else `~/.config/fwatch/config.yaml`. -- `fwatch.service` — example systemd **user** unit (ExecStart `/usr/local/bin/fwatch`). -- `packaging/fwatch.service` — the unit shipped in the `.deb` (ExecStart `/usr/bin/fwatch`); - keep it in sync with the root one, which targets source installs. +- `fwatch.service` — the systemd **user** unit, single source of truth: shipped in the + archives, installed live by the `.deb` and as docs by the AUR package. ExecStart is + `/usr/bin/fwatch`, the path both packages install to. - `.goreleaser.yml` — builds, archives, `.deb` packages (nfpms), AUR (`fwatch-bin`) publishing. - `.github/workflows/` — `test.yml` (vet/test/build on PRs and main), `release.yml` (goreleaser, triggered by `X.Y.Z` tags). diff --git a/README.md b/README.md index d1e763c..060ff9f 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,9 @@ systemctl --user status fwatch.service journalctl --user -u fwatch.service -f ``` +**Note:** The unit's `ExecStart` is `/usr/bin/fwatch`, where the deb and AUR packages install +the binary. If you installed manually to `/usr/local/bin`, edit `ExecStart` to match. + **Note:** Make sure you've already configured fwatch (see [Configuration](#configuration) section above) before starting the service. ## Configuration Options diff --git a/fwatch.service b/fwatch.service index caf3d15..7766502 100644 --- a/fwatch.service +++ b/fwatch.service @@ -5,8 +5,9 @@ After=network.target [Service] Type=simple -# Use absolute path to the fwatch binary -ExecStart=/usr/local/bin/fwatch +# Path the deb and AUR packages install the binary to. +# Adjust if you installed manually to /usr/local/bin. +ExecStart=/usr/bin/fwatch # Restart policy Restart=always diff --git a/packaging/fwatch.service b/packaging/fwatch.service deleted file mode 100644 index 901aee4..0000000 --- a/packaging/fwatch.service +++ /dev/null @@ -1,24 +0,0 @@ -[Unit] -Description=fwatch - Automatic file organizer -Documentation=https://github.com/polarn/fwatch -After=network.target - -[Service] -Type=simple -# Path used by the Debian package (the binary lands in /usr/bin) -ExecStart=/usr/bin/fwatch - -# Restart policy -Restart=always -RestartSec=10 - -# Security hardening -NoNewPrivileges=true -PrivateTmp=true - -# Logging -StandardOutput=journal -StandardError=journal - -[Install] -WantedBy=default.target