From c9798691c8aca50159f928c7f7bd62c8202d5c38 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Tue, 21 Apr 2026 01:10:56 +0200 Subject: [PATCH] action release --- .gitea/workflows/source-release.yml | 65 ++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/source-release.yml b/.gitea/workflows/source-release.yml index d4713aa..f218fcb 100644 --- a/.gitea/workflows/source-release.yml +++ b/.gitea/workflows/source-release.yml @@ -1,3 +1,4 @@ +# .gitea/workflows/source-release.yml name: Source release on: @@ -26,6 +27,8 @@ jobs: gcc \ g++ \ pkg-config \ + curl \ + jq \ libgdbm-dev \ libcrypt-dev @@ -35,15 +38,57 @@ jobs: - name: Build source package run: cmake --build build --target package_source - - name: List generated files + - name: Find source tarball + id: pkg run: | - find build -maxdepth 2 \( -name '*.tar.bz2' -o -name '*.tbz2' \) -print + FILE="$(find build -maxdepth 2 -type f -name '*.tar.bz2' | head -n1)" + test -n "$FILE" + echo "file=$FILE" >> "$GITHUB_OUTPUT" + echo "name=$(basename "$FILE")" >> "$GITHUB_OUTPUT" - - name: Upload workflow artifact - uses: actions/upload-artifact@v3 - with: - name: mars-nwe-source-package - path: | - build/*.tar.bz2 - build/*.tbz2 - if-no-files-found: error \ No newline at end of file + - name: Create release if missing + env: + GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }} + GITEA_API: https://gitea.disconnected-by-peer.at/api/v1 + OWNER: mars_nwe + REPO: mars-nwe + TAG: ${{ gitea.ref_name || github.ref_name }} + run: | + set -e + + RELEASE_JSON="$(curl -fsS \ + -H "Authorization: token ${GITEA_TOKEN}" \ + "${GITEA_API}/repos/${OWNER}/${REPO}/releases/tags/${TAG}" || true)" + + if [ -z "$RELEASE_JSON" ]; then + RELEASE_JSON="$(curl -fsS -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + "${GITEA_API}/repos/${OWNER}/${REPO}/releases" \ + -d "$(jq -n \ + --arg tag "$TAG" \ + --arg name "$TAG" \ + '{tag_name:$tag,name:$name,draft:false,prerelease:false}')" )" + fi + + echo "$RELEASE_JSON" > release.json + jq . release.json + + - name: Upload tarball to release + env: + GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }} + GITEA_API: https://gitea.disconnected-by-peer.at/api/v1 + OWNER: mars_nwe + REPO: mars-nwe + FILE: ${{ steps.pkg.outputs.file }} + NAME: ${{ steps.pkg.outputs.name }} + run: | + set -e + + RELEASE_ID="$(jq -r '.id' release.json)" + + curl -fsS -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @"${FILE}" \ + "${GITEA_API}/repos/${OWNER}/${REPO}/releases/${RELEASE_ID}/assets?name=${NAME}"