From 8e8ace85c50b4d1e50bc782ea627b71d1c422dc8 Mon Sep 17 00:00:00 2001 From: Blomios Date: Tue, 21 Apr 2026 22:07:42 +0200 Subject: [PATCH] ci: add Gitea Actions release workflow and release script Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/release.yml | 161 +++++++++++++++++++++++++++++++++++ release.sh | 61 +++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 .gitea/workflows/release.yml create mode 100755 release.sh diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..7e3fabd --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,161 @@ +name: Release + +on: + push: + tags: + - 'v*' + +env: + GITEA_URL: https://gitea.anthonybouteiller.ovh + GITEA_REPO: blomios/TougliGui + +jobs: + # ── Crée la release Gitea à partir du tag ──────────────────────────────── + create-release: + runs-on: [self-hosted, linux] + outputs: + release_id: ${{ steps.create.outputs.release_id }} + version: ${{ steps.version.outputs.version }} + steps: + - name: Extract version + id: version + run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT + + - name: Create Gitea release + id: create + run: | + RESPONSE=$(curl -s -X POST \ + "$GITEA_URL/api/v1/repos/$GITEA_REPO/releases" \ + -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "{ + \"tag_name\": \"$GITHUB_REF_NAME\", + \"name\": \"TougliGui $GITHUB_REF_NAME\", + \"body\": \"Release $GITHUB_REF_NAME\", + \"draft\": false, + \"prerelease\": false + }") + echo "release_id=$(echo $RESPONSE | python3 -c 'import json,sys; print(json.load(sys.stdin)[\"id\"])')" >> $GITHUB_OUTPUT + + # ── Build Linux ─────────────────────────────────────────────────────────── + build-linux: + needs: create-release + runs-on: [self-hosted, linux] + steps: + - uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Install system deps + run: | + sudo apt-get update + sudo apt-get install -y \ + libwebkit2gtk-4.1-dev libgtk-3-dev libayatana-appindicator3-dev \ + librsvg2-dev patchelf + + - name: Install npm deps + run: npm ci + + - name: Build + run: npm run tauri build + + - name: Upload artifacts + run: | + VERSION="${{ needs.create-release.outputs.version }}" + RELEASE_ID="${{ needs.create-release.outputs.release_id }}" + + upload() { + FILE="$1" + NAME=$(basename "$FILE") + curl -s -X POST \ + "$GITEA_URL/api/v1/repos/$GITEA_REPO/releases/$RELEASE_ID/assets?name=$NAME" \ + -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -F "attachment=@$FILE" + } + + find src-tauri/target/release/bundle/deb -name "*.deb" | while read f; do upload "$f"; done + find src-tauri/target/release/bundle/appimage -name "*.AppImage" | while read f; do upload "$f"; done + find src-tauri/target/release/bundle/rpm -name "*.rpm" | while read f; do upload "$f"; done + + # ── Build Windows ───────────────────────────────────────────────────────── + build-windows: + needs: create-release + runs-on: [self-hosted, windows] + steps: + - uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Install npm deps + run: npm ci + + - name: Build + run: npm run tauri build + + - name: Upload artifacts + shell: bash + run: | + RELEASE_ID="${{ needs.create-release.outputs.release_id }}" + + upload() { + FILE="$1" + NAME=$(basename "$FILE") + curl -s -X POST \ + "$GITEA_URL/api/v1/repos/$GITEA_REPO/releases/$RELEASE_ID/assets?name=$NAME" \ + -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -F "attachment=@$FILE" + } + + find src-tauri/target/release/bundle/nsis -name "*.exe" | while read f; do upload "$f"; done + find src-tauri/target/release/bundle/msi -name "*.msi" | while read f; do upload "$f"; done + + # ── Build macOS ─────────────────────────────────────────────────────────── + build-macos: + needs: create-release + runs-on: [self-hosted, macos] + steps: + - uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: aarch64-apple-darwin x86_64-apple-darwin + + - name: Install npm deps + run: npm ci + + - name: Build (universal) + run: npm run tauri build -- --target universal-apple-darwin + + - name: Upload artifacts + run: | + RELEASE_ID="${{ needs.create-release.outputs.release_id }}" + + upload() { + FILE="$1" + NAME=$(basename "$FILE") + curl -s -X POST \ + "$GITEA_URL/api/v1/repos/$GITEA_REPO/releases/$RELEASE_ID/assets?name=$NAME" \ + -H "Authorization: token ${{ secrets.RELEASE_TOKEN }}" \ + -F "attachment=@$FILE" + } + + find src-tauri/target/universal-apple-darwin/release/bundle/dmg -name "*.dmg" | while read f; do upload "$f"; done + find src-tauri/target/universal-apple-darwin/release/bundle/macos -name "*.app.tar.gz" | while read f; do upload "$f"; done diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..7449945 --- /dev/null +++ b/release.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +set -euo pipefail + +VERSION="${1:-}" + +if [[ -z "$VERSION" ]]; then + CURRENT=$(python3 -c "import json; print(json.load(open('src-tauri/tauri.conf.json'))['version'])") + echo "Version actuelle : $CURRENT" + read -rp "Nouvelle version (ex: 1.0.0) : " VERSION +fi + +# Retire un éventuel 'v' préfixé +VERSION="${VERSION#v}" + +if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Erreur : version invalide '$VERSION' (format attendu : X.Y.Z)" + exit 1 +fi + +echo "→ Mise à jour de la version vers $VERSION" + +# Mise à jour tauri.conf.json +python3 - "$VERSION" << 'EOF' +import json, sys +v = sys.argv[1] +path = "src-tauri/tauri.conf.json" +with open(path) as f: + data = json.load(f) +data["version"] = v +with open(path, "w") as f: + json.dump(data, f, indent=2, ensure_ascii=False) + f.write("\n") +EOF + +# Mise à jour package.json +python3 - "$VERSION" << 'EOF' +import json, sys +v = sys.argv[1] +path = "package.json" +with open(path) as f: + data = json.load(f) +data["version"] = v +with open(path, "w") as f: + json.dump(data, f, indent=2, ensure_ascii=False) + f.write("\n") +EOF + +echo "→ Commit de version" +git add src-tauri/tauri.conf.json package.json +git commit -m "chore: bump version to $VERSION" + +echo "→ Création du tag v$VERSION" +git tag "v$VERSION" + +echo "→ Push vers Gitea" +git push origin main +git push origin "v$VERSION" + +echo "" +echo "✓ Tag v$VERSION poussé — le workflow Gitea Actions va builder et créer la release automatiquement." +echo " Suivi : https://gitea.anthonybouteiller.ovh/blomios/TougliGui/actions"