From 50520016c8da7a765b638de064cd0c8aa52a7b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Sat, 16 Aug 2025 19:39:54 -0700 Subject: [PATCH] feat(packaging): use GoReleaser instead of Docker to build RPM/Debian packages --- .github/workflows/packages.yml | 92 ++++++++++++++++++++++++++++++ .gitignore | 5 +- Makefile | 2 +- packaging/goreleaser.yaml | 65 +++++++++++++++++++++ packaging/systemd/miniflux.service | 2 +- 5 files changed, 162 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/packages.yml create mode 100644 packaging/goreleaser.yaml diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml new file mode 100644 index 00000000..45a0215b --- /dev/null +++ b/.github/workflows/packages.yml @@ -0,0 +1,92 @@ +name: RPM and Debian Packages +permissions: read-all +on: + workflow_dispatch: + pull_request: + branches: [ main ] + paths: + - 'packaging/**' # Only run on changes to the packaging files +jobs: + build-packages: + name: Build Packages + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Set up Golang + uses: actions/setup-go@v5 + with: + go-version: stable + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: '~> v2' + args: release -f packaging/goreleaser.yaml --clean ${{ github.event_name == 'pull_request' && '--snapshot' || '' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Cache Packages + uses: actions/cache/save@v4 + with: + path: | + dist/*.deb + dist/*.rpm + key: packages-${{ github.run_id }}-${{ github.run_attempt }} + - name: Upload Artifacts + if: github.event_name != 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: packages + path: | + dist/*.deb + dist/*.rpm + if-no-files-found: error + retention-days: 1 + compression-level: 0 + test-debian-package: + name: Test Debian Package + runs-on: ubuntu-latest + needs: build-packages + services: + postgres: + image: postgres:9.5 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: miniflux2 + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: + - name: Restore Packages Cache + uses: actions/cache/restore@v4 + with: + path: | + dist/*.deb + dist/*.rpm + key: packages-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true + - name: Install Debian Package + run: | + sudo apt-get update + sudo dpkg -i dist/miniflux*amd64.deb + - name: Test Installation + run: | + which miniflux + miniflux -i + - name: Test Systemd Service + run: | + # Verify service file exists and is properly installed + systemctl cat miniflux + + # Check if service is enabled by default + sudo systemctl is-enabled miniflux || echo "Service not enabled by default" + + # Check service status (should be inactive/dead but loadable) + sudo systemctl status miniflux --no-pager || true + + # Verify service can be started (will fail due to missing config, but should load) + sudo systemctl start miniflux || echo "Service failed to start (expected without proper config)" + + # Check if service is properly defined + systemctl show miniflux --property=Type,ExecStart,User,Group --no-pager diff --git a/.gitignore b/.gitignore index 0a23210f..0a7b46b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ ./*.sha256 -/miniflux .idea .vscode *.deb *.rpm -miniflux-* +/miniflux +dist +miniflux-* \ No newline at end of file diff --git a/Makefile b/Makefile index c17ee550..e7c66b18 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,7 @@ run: @ LOG_DATE_TIME=1 LOG_LEVEL=debug RUN_MIGRATIONS=1 CREATE_ADMIN=1 ADMIN_USERNAME=admin ADMIN_PASSWORD=test123 go run main.go clean: - @ rm -f $(APP)-* $(APP) $(APP)*.rpm $(APP)*.deb $(APP)*.exe $(APP)*.sha256 + @ rm -rf $(APP)-* $(APP) $(APP)*.rpm $(APP)*.deb $(APP)*.exe $(APP)*.sha256 dist add-string: cd internal/locale/translations && \ diff --git a/packaging/goreleaser.yaml b/packaging/goreleaser.yaml new file mode 100644 index 00000000..2580362b --- /dev/null +++ b/packaging/goreleaser.yaml @@ -0,0 +1,65 @@ +version: 2 + +builds: + - id: miniflux + binary: miniflux + env: + - CGO_ENABLED=0 + goos: + - linux + # We will enable cross-compilation for other OSes later + # - darwin + # - freebsd + # - openbsd + goarch: + - amd64 + - arm64 + - arm + goarm: + - 6 + - 7 + ignore: + - goos: darwin + goarch: arm + - goos: darwin + goarch: amd64 + - goos: freebsd + goarch: arm64 + - goos: freebsd + goarch: arm + - goos: openbsd + goarch: arm64 + - goos: openbsd + goarch: arm + ldflags: + - "-s -w -X miniflux.app/v2/internal/version.Version={{.Version}}" + +nfpms: + - id: miniflux-packages + package_name: miniflux + vendor: Miniflux + maintainer: "Frédéric Guillot " + description: "Minimalist and opinionated feed reader" + homepage: "https://miniflux.app/" + license: Apache 2.0 + file_name_template: "{{ .PackageName }}_{{ .Version }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}" + formats: + - deb + - rpm + contents: + - src: "./packaging/miniflux.conf" + dst: "/etc/miniflux.conf" + file_info: + mode: 0644 + - src: "./packaging/systemd/miniflux.service" + dst: "/etc/systemd/system/miniflux.service" + file_info: + mode: 0644 + - src: "./miniflux.1" + dst: "/usr/share/man/man1/miniflux.1" + file_info: + mode: 0644 + deb: + lintian_overrides: + - statically-linked-binary + - changelog-file-missing-in-native-package \ No newline at end of file diff --git a/packaging/systemd/miniflux.service b/packaging/systemd/miniflux.service index 6132ee53..5fd33c60 100644 --- a/packaging/systemd/miniflux.service +++ b/packaging/systemd/miniflux.service @@ -13,7 +13,7 @@ After=network.target postgresql.service [Service] ExecStart=/usr/bin/miniflux -User=miniflux +DynamicUser=yes # Load environment variables from /etc/miniflux.conf. EnvironmentFile=/etc/miniflux.conf