From f1e3b4907e98b79c9b1c31bd4958bce5f886ddce Mon Sep 17 00:00:00 2001 From: Ginger Date: Tue, 23 Sep 2025 19:53:37 +0000 Subject: [PATCH] Build Debian packages and upload them to Forgejo's repository (#996) This uses the existing `cargo-deb` metadata. Reviewed-on: https://forgejo.ellis.link/continuwuation/continuwuity/pulls/996 Reviewed-by: Tom Foster Reviewed-by: nex Co-authored-by: Ginger Co-committed-by: Ginger --- .forgejo/workflows/build-debian.yml | 148 ++++++++++++++++++++++++++++ pkg/debian/README.md | 24 ++++- src/main/Cargo.toml | 8 +- 3 files changed, 173 insertions(+), 7 deletions(-) create mode 100644 .forgejo/workflows/build-debian.yml diff --git a/.forgejo/workflows/build-debian.yml b/.forgejo/workflows/build-debian.yml new file mode 100644 index 00000000..a4793a85 --- /dev/null +++ b/.forgejo/workflows/build-debian.yml @@ -0,0 +1,148 @@ +name: Build / Debian DEB + +concurrency: + group: "build-debian-${{ forge.ref }}" + cancel-in-progress: true + +on: + push: + tags: + - "v*.*.*" + workflow_dispatch: + schedule: + - cron: '30 0 * * *' + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + container: ["ubuntu-latest", "ubuntu-previous", "debian-latest", "debian-oldstable"] + container: + image: "ghcr.io/tcpipuk/act-runner:${{ matrix.container }}" + + steps: + - name: Get Debian version + id: debian-version + run: | + VERSION=$(cat /etc/debian_version) + DISTRIBUTION=$(lsb_release -sc 2>/dev/null) + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "distribution=$DISTRIBUTION" >> $GITHUB_OUTPUT + echo "Debian distribution: $DISTRIBUTION ($VERSION)" + + - name: Checkout repository with full history + uses: https://code.forgejo.org/actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Cache Cargo registry + uses: https://code.forgejo.org/actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-debian-${{ steps.debian-version.outputs.distribution }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + cargo-debian-${{ steps.debian-version.outputs.distribution }}- + + - name: Setup sccache + uses: https://git.tomfos.tr/tom/sccache-action@v1 + + - name: Configure sccache environment + run: | + echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV + echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV + echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> $GITHUB_ENV + echo "SCCACHE_CACHE_SIZE=10G" >> $GITHUB_ENV + # Aggressive GC since cache restores don't increment counter + echo "CARGO_INCREMENTAL_GC_TRIGGER=5" >> $GITHUB_ENV + + - name: Setup Rust nightly + uses: ./.forgejo/actions/setup-rust + with: + rust-version: nightly + github-token: ${{ secrets.GH_PUBLIC_RO }} + + - name: Get package version and component + id: package-meta + run: | + BASE_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r ".packages[] | select(.name == \"conduwuit\").version" | sed 's/[^a-zA-Z0-9.+]/~/g') + # VERSION is the package version, COMPONENT is used in + # apt's repository config like a git repo branch + if [[ "${{ forge.ref }}" == "refs/tags/"* ]]; then + # Use the "stable" component for tagged releases + COMPONENT="stable" + VERSION=$BASE_VERSION + else + # Use the "dev" component for development builds + SHA=$(echo "${{ forge.sha }}" | cut -c1-7) + DATE=$(date +%Y%m%d) + if [ "${{ forge.ref_name }}" = "main" ]; then + COMPONENT="dev" + else + # Use the sanitized ref name as the component for feature branches + COMPONENT="dev-$(echo '${{ forge.ref_name }}' | sed 's/[^a-zA-Z0-9.+]/-/g' | tr '[:upper:]' '[:lower:]' | cut -c1-30)" + fi + CLEAN_COMPONENT=$(echo $COMPONENT | sed 's/[^a-zA-Z0-9.+]/~/g') + VERSION="$BASE_VERSION~git$DATE.$SHA-$CLEAN_COMPONENT" + fi + echo "component=$COMPONENT" >> $GITHUB_OUTPUT + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Component: $COMPONENT" + echo "Version: $VERSION" + + - name: Install cargo-deb + run: | + if command -v cargo-deb &> /dev/null; then + echo "cargo-deb already available" + else + echo "Installing cargo-deb" + cargo-binstall -y --no-symlinks cargo-deb + fi + + - name: Install build dependencies + run: | + apt-get update -y + # Build dependencies for rocksdb + apt-get install -y clang liburing-dev + + - name: Run cargo-deb + id: cargo-deb + run: | + DEB_PATH=$(cargo deb --deb-version ${{ steps.package-meta.outputs.version }}) + echo "path=$DEB_PATH" >> $GITHUB_OUTPUT + + - name: Test deb installation + run: | + echo "Installing: ${{ steps.cargo-deb.outputs.path }}" + + apt-get install -y ${{ steps.cargo-deb.outputs.path }} + + dpkg -s continuwuity + + [ -f /usr/bin/conduwuit ] && echo "✅ Binary installed successfully" + [ -f /usr/lib/systemd/system/conduwuit.service ] && echo "✅ Systemd service installed" + [ -f /etc/conduwuit/conduwuit.toml ] && echo "✅ Config file installed" + + - name: Upload deb artifact + uses: https://code.forgejo.org/actions/upload-artifact@v3 + with: + name: continuwuity-${{ steps.debian-version.outputs.distribution }} + path: ${{ steps.cargo-deb.outputs.path }} + + - name: Publish to Forgejo package registry + if: ${{ forge.event_name == 'push' || forge.event_name == 'workflow_dispatch' }} + run: | + OWNER="continuwuation" + DISTRIBUTION=${{ steps.debian-version.outputs.distribution }} + COMPONENT=${{ steps.package-meta.outputs.component }} + DEB=${{ steps.cargo-deb.outputs.path }} + + echo "Publishing: $DEB in component $COMPONENT for distribution $DISTRIBUTION" + + curl --fail-with-body \ + -X PUT \ + -H "Authorization: token ${{ secrets.BUILTIN_REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}" \ + --upload-file "$DEB" \ + "${{ forge.server_url }}/api/packages/$OWNER/debian/pool/$DISTRIBUTION/$COMPONENT/upload" diff --git a/pkg/debian/README.md b/pkg/debian/README.md index b605b198..4d24cbc6 100644 --- a/pkg/debian/README.md +++ b/pkg/debian/README.md @@ -1,12 +1,28 @@ # Continuwuity for Debian -This document provides information about downloading and deploying the Debian package. You can also use this guide for other `apt`-based distributions such as Ubuntu. +This document provides information about downloading and deploying the Debian package. You can also use this guide for other deb-based distributions such as Ubuntu. ### Installation -See the [generic deployment guide](../deploying/generic.md) for additional information about using the Debian package. +To add the Continuwuation apt repository: +```bash +# Replace with `"dev"` for bleeding-edge builds at your own risk +export COMPONENT="stable" +# Import the Continuwuation signing key +sudo curl https://forgejo.ellis.link/api/packages/continuwuation/debian/repository.key -o /etc/apt/keyrings/forgejo-continuwuation.asc +# Add a new apt source list pointing to the repository +echo "deb [signed-by=/etc/apt/keyrings/forgejo-continuwuation.asc] https://forgejo.ellis.link/api/packages/continuwuation/debian $(lsb_release -sc) $COMPONENT" | sudo tee /etc/apt/sources.list.d/continuwuation.list +# Update remote package lists +sudo apt update +``` -No `apt` repository is currently available. This feature is in development. +To install continuwuity: +```bash +sudo apt install continuwuity +``` +The `continuwuity` package conflicts with the old `conduwuit` package and will remove it automatically when installed. + +See the [generic deployment guide](../deploying/generic.md) for additional information about using the Debian package. ### Configuration @@ -16,7 +32,7 @@ You can customize additional settings by uncommenting and modifying the configur ### Running -The package uses the [`conduwuit.service`](../configuration/examples.md#example-systemd-unit-file) systemd unit file to start and stop Continuwuity. The binary installs at `/usr/sbin/conduwuit`. +The package uses the [`conduwuit.service`](../configuration/examples.md#example-systemd-unit-file) systemd unit file to start and stop Continuwuity. The binary installs at `/usr/bin/conduwuit`. By default, this package assumes that Continuwuity runs behind a reverse proxy. The default configuration options apply (listening on `localhost` and TCP port `6167`). Matrix federation requires a valid domain name and TLS. To federate properly, you must set up TLS certificates and certificate renewal. diff --git a/src/main/Cargo.toml b/src/main/Cargo.toml index 388ad503..8031e068 100644 --- a/src/main/Cargo.toml +++ b/src/main/Cargo.toml @@ -22,11 +22,13 @@ crate-type = [ ] [package.metadata.deb] -name = "conduwuit" -maintainer = "strawberry " -copyright = "2024, strawberry " +name = "continuwuity" +maintainer = "continuwuity developers " +copyright = "2024, continuwuity developers" license-file = ["../../LICENSE", "3"] depends = "$auto, ca-certificates" +breaks = ["conduwuit (<<0.5.0)"] +replaces = ["conduwuit (<<0.5.0)"] extended-description = """\ a cool hard fork of Conduit, a Matrix homeserver written in Rust""" section = "net"