Adding publishing of artifacts
release / build (push) Successful in 4m53s

This commit is contained in:
ml
2026-07-16 21:31:01 +02:00
parent 5ac145bff6
commit f65b9be1df
5 changed files with 47 additions and 9 deletions
+38 -5
View File
@@ -56,13 +56,46 @@ jobs:
set -euo pipefail
API="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}"
AUTH="Authorization: token ${{ secrets.GITEA_TOKEN }}"
TAG="${{ gitea.ref_name }}"
RELEASE_ID="$(curl -sf -X POST "$API/releases" \
-H "$AUTH" -H "Content-Type: application/json" \
-d "{\"tag_name\": \"${{ gitea.ref_name }}\", \"name\": \"${{ gitea.ref_name }}\"}" \
| jq -r .id)"
# Reuse an existing release for this tag instead of failing outright
# (curl -f exit 22) if a prior run already created it — e.g. a retry
# after a later step failed. (No -f here: a 404 for "no release yet"
# is expected, not an error — it just leaves .id empty below.)
RELEASE_ID="$(curl -s "$API/releases/tags/$TAG" -H "$AUTH" | jq -r '.id // empty')"
if [ -z "$RELEASE_ID" ]; then
RELEASE_ID="$(curl -sf -X POST "$API/releases" \
-H "$AUTH" -H "Content-Type: application/json" \
-d "{\"tag_name\": \"$TAG\", \"name\": \"$TAG\"}" \
| jq -r .id)"
fi
for f in dist/*; do
curl -sf -X POST "$API/releases/$RELEASE_ID/assets?name=$(basename "$f")" \
NAME="$(basename "$f")"
# Same idempotency concern for assets: a retry re-uploading a name
# that's already attached would 409, so replace it instead.
EXISTING_ID="$(curl -sf "$API/releases/$RELEASE_ID/assets" -H "$AUTH" \
| jq -r --arg n "$NAME" '.[] | select(.name == $n) | .id')"
if [ -n "$EXISTING_ID" ]; then
curl -sf -X DELETE "$API/releases/$RELEASE_ID/assets/$EXISTING_ID" -H "$AUTH"
fi
curl -sf -X POST "$API/releases/$RELEASE_ID/assets?name=$NAME" \
-H "$AUTH" -F "attachment=@$f"
done
- name: Publish to dl.ladkau.de
run: |
set -euo pipefail
mkdir -p ~/.ssh
echo "${{ secrets.DL_SFTP_KEY }}" > ~/.ssh/dl_sftp_key
chmod 600 ~/.ssh/dl_sftp_key
BATCH="$(mktemp)"
{
echo "-mkdir files/schwert-und-magie"
for f in dist/*; do
echo "put $f files/schwert-und-magie/$(basename "$f")"
done
} > "$BATCH"
sftp -i ~/.ssh/dl_sftp_key -P 2223 \
-o StrictHostKeyChecking=accept-new \
-b "$BATCH" uploader@dl.ladkau.de
+1 -1
View File
@@ -6,7 +6,7 @@
.cxx
local.properties
.lock*
.idea
/SchwertUndMagieOnPebbleCompanionApp/local.properties
/SchwertUndMagieOnPebbleCompanionApp/.idea/caches
/SchwertUndMagieOnPebbleCompanionApp/.idea/libraries
+2 -1
View File
@@ -25,6 +25,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
# git/unzip/curl/jq: checkout, SDK downloads, and the release workflow's
# calls to the Gitea API (create release, upload assets).
# openssh-client: the release workflow's `sftp` upload to dl.ladkau.de.
# python3-venv: pebble-tool's `sdk install` creates a venv per SDK version.
# dos2unix/autoconf/automake/pkg-config/xa65/build-essential/gettext/flex/bison:
# host tools required by the companion app's build_vice.sh (see that file's
@@ -32,7 +33,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
# based configure) to cross-compile VICE via autotools before NDK clang takes
# over for the actual target compilation.
RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates git unzip tar xz-utils python3 python3-venv file jq \
curl ca-certificates git unzip tar xz-utils python3 python3-venv file jq openssh-client \
dos2unix autoconf automake pkg-config xa65 build-essential gettext flex bison \
&& rm -rf /var/lib/apt/lists/*
+1 -1
View File
@@ -1 +1 @@
3
4
+5 -1
View File
@@ -326,6 +326,7 @@ Settings → Actions → Secrets, add:
| `RELEASE_KEYSTORE_PROPERTIES` | the full contents of `SchwertUndMagieOnPebbleCompanionApp/keystore.properties` (§2.2) |
| `REGISTRY_USER` | same as `REGISTRY_USER` in `registry.env` |
| `REGISTRY_PASSWORD` | same as `REGISTRY_PASSWORD` in `registry.env` |
| `DL_SFTP_KEY` | private key (PEM) for the `uploader` SFTP account on dl.ladkau.de |
`secrets.GITEA_TOKEN` (used to create the release and upload assets) is
Gitea's own auto-generated per-job token — nothing to create or add yourself.
@@ -341,7 +342,10 @@ git push origin v1.2.3
```
Watch the run under the repo's Actions tab. On success, the release appears
under the repo's Releases page with the three versioned artifacts attached.
under the repo's Releases page with the three versioned artifacts attached,
and the same three files are uploaded over SFTP to
`dl.ladkau.de:files/schwert-und-magie/` (using the `DL_SFTP_KEY` secret,
§4.3) for direct download outside of Gitea.
To build the same versioned artifacts locally without pushing a tag (e.g. to
test before releasing), either run `dist.sh` directly with the host toolchain: