From f65b9be1dfdbb8ed4238e88e512328f184be64c2 Mon Sep 17 00:00:00 2001 From: ml Date: Thu, 16 Jul 2026 21:31:01 +0200 Subject: [PATCH] Adding publishing of artifacts --- .gitea/workflows/release.yml | 43 +++++++++++++++++++++++++++++++----- .gitignore | 2 +- build-image/Dockerfile | 3 ++- build-image/VERSION | 2 +- docs/publish.md | 6 ++++- 5 files changed, 47 insertions(+), 9 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 624e66f..58ac556 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -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 diff --git a/.gitignore b/.gitignore index c77237b..188f771 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ .cxx local.properties .lock* - +.idea /SchwertUndMagieOnPebbleCompanionApp/local.properties /SchwertUndMagieOnPebbleCompanionApp/.idea/caches /SchwertUndMagieOnPebbleCompanionApp/.idea/libraries diff --git a/build-image/Dockerfile b/build-image/Dockerfile index 6ededdd..a3277ce 100644 --- a/build-image/Dockerfile +++ b/build-image/Dockerfile @@ -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/* diff --git a/build-image/VERSION b/build-image/VERSION index 00750ed..b8626c4 100644 --- a/build-image/VERSION +++ b/build-image/VERSION @@ -1 +1 @@ -3 +4 diff --git a/docs/publish.md b/docs/publish.md index 01cf167..001b8ac 100644 --- a/docs/publish.md +++ b/docs/publish.md @@ -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: