From 39fb2a270af1fd955b0ef3a0204e2687b0453673 Mon Sep 17 00:00:00 2001 From: Bjorn Blomberg Date: Tue, 14 Jul 2026 19:44:35 +0200 Subject: [PATCH] Add Gitea Actions release workflow + combined VS Code build task Same pattern as TUI-WM: rolling 'latest' release with linux x64 + arm64 binaries built on the Pi5 runner. Co-Authored-By: Claude Fable 5 --- .gitea/workflows/release.yaml | 68 +++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 9 +++++ 2 files changed, 77 insertions(+) create mode 100644 .gitea/workflows/release.yaml diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..7276a83 --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,68 @@ +name: release + +# På varje push till master/main: kör tester, bygg release-binärer för +# linux arm64 (nativt på Pi5-runnern) + linux x64 (cross) och lägg dem +# på en rullande "latest"-release på släppsidan i Gitea. +on: + push: + branches: [master, main] + workflow_dispatch: {} + +jobs: + build-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Installera Rust + cross-toolchain + run: | + set -e + sudo apt-get update -qq + sudo apt-get install -y -qq gcc-x86-64-linux-gnu jq curl + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ + | sh -s -- -y --profile minimal --default-toolchain stable + . "$HOME/.cargo/env" + rustup target add x86_64-unknown-linux-gnu + + - name: Testa + bygg (arm64 nativt + x64 cross) + run: | + set -e + . "$HOME/.cargo/env" + # Snäll mot Pi5:n — låg prio och max 2 parallella jobb + export CARGO_BUILD_JOBS=2 + nice -n 10 cargo test --release + nice -n 10 cargo build --release + export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc + nice -n 10 cargo build --release --target x86_64-unknown-linux-gnu + mkdir -p build + cp target/release/tui-fm build/tui-fm-linux-arm64 + cp target/x86_64-unknown-linux-gnu/release/tui-fm build/tui-fm-linux-x64 + (cd build && sha256sum tui-fm-linux-* > checksums.txt && ls -la) + + - name: Skapa/uppdatera latest-release + ladda upp binärer + env: + API: http://gitea-d:3000/api/v1 + REPO: ${{ github.repository }} + TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -e + TAG="latest" + BODY="Rullande bygge från senaste master. Commit: ${{ github.sha }}. Arkitekturer: linux x64 + arm64 (Pi5)." + rid=$(curl -s -X POST "$API/repos/$REPO/releases" \ + -H "Authorization: token $TOKEN" -H 'Content-Type: application/json' \ + -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"$BODY\"}" | jq -r '.id // empty') + [ -z "$rid" ] && rid=$(curl -s "$API/repos/$REPO/releases/tags/$TAG" \ + -H "Authorization: token $TOKEN" | jq -r '.id') + echo "release id: $rid" + for f in tui-fm-linux-x64 tui-fm-linux-arm64 checksums.txt; do + aid=$(curl -s "$API/repos/$REPO/releases/$rid/assets" \ + -H "Authorization: token $TOKEN" | jq -r ".[] | select(.name==\"$f\") | .id") + if [ -n "$aid" ] && [ "$aid" != "null" ]; then + curl -s -X DELETE "$API/repos/$REPO/releases/$rid/assets/$aid" \ + -H "Authorization: token $TOKEN" -o /dev/null + fi + curl -s -X POST "$API/repos/$REPO/releases/$rid/assets?name=$f" \ + -H "Authorization: token $TOKEN" \ + -F "attachment=@build/$f" -o /dev/null -w " $f -> HTTP %{http_code}\n" + done diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 4d33caf..354622f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,6 +1,15 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Build alla (Linux + Windows)", + "type": "shell", + "command": "cargo build --release && cargo build --release --target x86_64-pc-windows-gnu && mkdir -p build/linux build/windows && cp target/release/tui-fm build/linux/tui-fm && cp target/x86_64-pc-windows-gnu/release/tui-fm.exe build/windows/tui-fm.exe && echo 'Done: build/linux/tui-fm + build/windows/tui-fm.exe'", + "group": "build", + "presentation": { "reveal": "always", "panel": "shared" }, + "problemMatcher": "$rustc", + "detail": "Bygger båda binärerna: Linux (native) + Windows (kräver mingw-w64)" + }, { "label": "Build - Linux", "type": "shell",