Public Access
added release upload to workflow
This commit is contained in:
1 parent
458715c19a
commit
14b74767fc
1 file changed
+52
-12
@@ -2,8 +2,7 @@ name: Build Debian Packages
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
tags: [ "v*" ] # releases are tag-driven now
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -23,7 +22,7 @@ jobs:
|
|||||||
- name: Install Node.js and git
|
- name: Install Node.js and git
|
||||||
run: |
|
run: |
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get -y install nodejs git lsb-release
|
apt-get -y install nodejs git lsb-release jq
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -31,20 +30,61 @@ jobs:
|
|||||||
github-server-url: https://gitea.pkm.physik.tu-darmstadt.de
|
github-server-url: https://gitea.pkm.physik.tu-darmstadt.de
|
||||||
|
|
||||||
- name: Install build dependencies
|
- name: Install build dependencies
|
||||||
run: |
|
run: bash requirements.debian
|
||||||
bash requirements.debian
|
|
||||||
|
|
||||||
- name: Build Package
|
- name: Build Package
|
||||||
run: |
|
run: dpkg-buildpackage -us -uc -b
|
||||||
dpkg-buildpackage -us -uc -b
|
|
||||||
|
|
||||||
- name: Collect Artifacts
|
- name: Collect Artifacts
|
||||||
run: |
|
run: |
|
||||||
mkdir -p artifacts
|
mkdir -p artifacts
|
||||||
mv -v ../*.deb artifacts/
|
mv -v ../*.deb artifacts/
|
||||||
|
|
||||||
- name: Upload Artifacts
|
- name: Publish release with assets
|
||||||
uses: actions/upload-artifact@v3
|
env:
|
||||||
with:
|
GITEA_TOKEN: ${{ secrets.DEB_UPLOAD_TOKEN }}
|
||||||
name: python3-damaris-${{ matrix.codename }}.gz
|
SLUG: ${{ gitea.repository }} # owner/repo
|
||||||
path: artifacts/*.deb
|
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
|
||||||
|
|
||||||
Reference in new issue
Block a user