Files
python3-damaris/.gitea/workflows/debian-build.yml
T
markusro e5e1a111d8
Build Debian Packages / build (bookworm, debian12) (push) Successful in 9m9s
Build Debian Packages / build (trixie, debian13) (push) Successful in 9m14s
added release upload to workflow
2026-10-18 19:36:21 +02:00

91 lines
2.9 KiB
YAML

name: Build Debian Packages
on:
push:
tags: [ "v*" ] # releases are tag-driven now
workflow_dispatch:
jobs:
build:
strategy:
matrix:
target: [debian12, debian13]
include:
- target: debian12
codename: bookworm
- target: debian13
codename: trixie
runs-on: ${{ matrix.target }}
steps:
- name: Install Node.js and git
run: |
apt-get update
apt-get -y install nodejs git lsb-release jq
- name: Checkout repository
uses: actions/checkout@v3
with:
github-server-url: https://gitea.pkm.physik.tu-darmstadt.de
- name: Install build dependencies
run: bash requirements.debian
- name: Build Package
run: dpkg-buildpackage -us -uc -b
- name: Collect Artifacts
run: |
mkdir -p artifacts
mv -v ../*.deb artifacts/
- name: Publish release with assets
env:
GITEA_TOKEN: ${{ secrets.DEB_UPLOAD_TOKEN }}
SLUG: ${{ gitea.repository }} # owner/repo
TAG: ${{ gitea.ref_name }} # e.g. v1.2.3
CODENAME: ${{ matrix.codename }}
run: |
set -euo pipefail
API="https://gitea.pkm.physik.tu-darmstadt.de/api/v1"
AUTH="Authorization: token ${GITEA_TOKEN}"
# 1. Find an existing release for this tag, if any
release_id=$(curl -s -H "$AUTH" \
"$API/repos/$SLUG/releases/tags/$TAG" | jq -r '.id // empty')
# 2. Create the release if it does not exist yet
if [ -z "$release_id" ]; then
echo "Creating release $TAG"
release_id=$(curl -s -X POST -H "$AUTH" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg tag "$TAG" \
'{tag_name:$tag, name:$tag, draft:false, prerelease:false}')" \
"$API/repos/$SLUG/releases" | jq -r '.id')
else
echo "Reusing existing release $TAG (id=$release_id)"
fi
echo "release_id=$release_id"
# 3. Upload each .deb as an asset
for deb in artifacts/*.deb; do
asset="${CODENAME}_$(basename "$deb")" # avoid bookworm/trixie name clash
echo "Uploading $asset"
# delete any existing asset with the same name (idempotent re-runs)
existing=$(curl -s -H "$AUTH" \
"$API/repos/$SLUG/releases/$release_id/assets" \
| jq -r --arg n "$asset" '.[] | select(.name==$n) | .id')
if [ -n "$existing" ]; then
curl -s -X DELETE -H "$AUTH" \
"$API/repos/$SLUG/releases/$release_id/assets/$existing"
fi
curl --fail --show-error --silent \
-X POST -H "$AUTH" \
-F "attachment=@$deb;filename=$asset" \
"$API/repos/$SLUG/releases/$release_id/assets"
done