mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-09 13:53:03 +02:00
152 lines
5.3 KiB
YAML
152 lines
5.3 KiB
YAML
name: Build / Debian DEB
|
|
|
|
concurrency:
|
|
group: "build-debian-${{ forge.ref }}"
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
tags:
|
|
- 'v*'
|
|
paths:
|
|
- 'pkg/debian/**'
|
|
- 'src/**'
|
|
- 'Cargo.toml'
|
|
- 'Cargo.lock'
|
|
- '.forgejo/workflows/build-debian.yml'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
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: Get package revision and component
|
|
id: package-meta
|
|
run: |
|
|
BASE_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r ".packages[] | select(.name == \"conduwuit\").version" | sed 's/~/-/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
|
|
COMPONENT="stable"
|
|
VERSION=$BASE_VERSION
|
|
else
|
|
SHA=$(echo "${{ forge.sha }}" | cut -c1-7)
|
|
DATE=$(date +%Y%M%d)
|
|
if [ "${{ forge.ref_name }}" = "main" ]; then
|
|
COMPONENT="dev"
|
|
else
|
|
# Use sanitized ref name for the component
|
|
COMPONENT=$(echo "${{ forge.ref_name }}" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]' | cut -c1-30)
|
|
fi
|
|
VERSION="$BASE_VERSION~git$DATE.$SHA-$COMPONENT"
|
|
fi
|
|
echo "component=$COMPONENT" >> $GITHUB_OUTPUT
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "Component: $COMPONENT"
|
|
echo "Version: $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.version }}-${{ hashFiles('**/Cargo.lock') }}
|
|
restore-keys: |
|
|
cargo-debian${{ steps.debian_version.outputs.version }}-
|
|
|
|
- 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: Check cargo-deb version
|
|
id: cargo-deb-version
|
|
run: echo "version=$(curl -s \"https://index.crates.io/ca/rg/cargo-deb\" | tail -n1 | jq -r .vers)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache cargo-deb installation
|
|
id: cache-cargo-deb
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.cargo/bin/cargo-deb
|
|
key: ${{ steps.cargo-deb-version.outputs.version }}
|
|
|
|
- name: Install cargo-deb
|
|
if: steps.cache-cargo-deb.outputs.cache-hit != 'true'
|
|
run: cargo binstall cargo-deb
|
|
|
|
- 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: Install build dependencies
|
|
run: |
|
|
apt-get update -y
|
|
# Build dependencies for rocksdb
|
|
apt-get install -y clang liburing-dev
|
|
|
|
- name: Test deb installation
|
|
run: |
|
|
echo "Installing: ${{ steps.cargo-deb.outputs.path }}"
|
|
|
|
apt install -y ${{ steps.cargo-deb.outputs.path }}
|
|
|
|
apt info 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
|
|
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"
|