diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 00000000..f560480d --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,137 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + build-linux-amd64: + runs-on: linux-amd64 + container: + image: rust:1.88-slim + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + apt-get update -qq && apt-get install -y -qq \ + libwebkit2gtk-4.1-dev libssl-dev libgtk-3-dev \ + libayatana-appindicator3-dev librsvg2-dev patchelf \ + pkg-config curl perl + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - + apt-get install -y nodejs + - name: Build + run: | + npm ci --legacy-peer-deps + rustup target add x86_64-unknown-linux-gnu + cargo install tauri-cli --version "^2" --locked + CI=true cargo tauri build --target x86_64-unknown-linux-gnu + - name: Collect artifacts + run: | + mkdir -p artifacts + find src-tauri/target/x86_64-unknown-linux-gnu/release/bundle \ + \( -name "*.deb" -o -name "*.rpm" -o -name "*.AppImage" \) \ + -exec cp {} artifacts/ \; + - uses: actions/upload-artifact@v4 + with: + name: linux-amd64 + path: artifacts/ + + build-windows-amd64: + runs-on: linux-amd64 + container: + image: rust:1.88-slim + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + apt-get update -qq && apt-get install -y -qq mingw-w64 curl nsis perl make + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - + apt-get install -y nodejs + - name: Build + env: + CC_x86_64_pc_windows_gnu: x86_64-w64-mingw32-gcc + CXX_x86_64_pc_windows_gnu: x86_64-w64-mingw32-g++ + AR_x86_64_pc_windows_gnu: x86_64-w64-mingw32-ar + CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: x86_64-w64-mingw32-gcc + run: | + npm ci --legacy-peer-deps + rustup target add x86_64-pc-windows-gnu + cargo install tauri-cli --version "^2" --locked + CI=true cargo tauri build --target x86_64-pc-windows-gnu + - name: Collect artifacts + run: | + mkdir -p artifacts + find src-tauri/target/x86_64-pc-windows-gnu/release/bundle \ + \( -name "*.exe" -o -name "*.msi" \) \ + -exec cp {} artifacts/ \; 2>/dev/null || true + - uses: actions/upload-artifact@v4 + with: + name: windows-amd64 + path: artifacts/ + + build-linux-arm64: + runs-on: linux-arm64 + container: + image: rust:1.88-slim + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: | + apt-get update -qq && apt-get install -y -qq \ + libwebkit2gtk-4.1-dev libssl-dev libgtk-3-dev \ + libayatana-appindicator3-dev librsvg2-dev patchelf \ + pkg-config curl perl + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - + apt-get install -y nodejs + - name: Build + run: | + npm ci --legacy-peer-deps + rustup target add aarch64-unknown-linux-gnu + cargo install tauri-cli --version "^2" --locked + CI=true cargo tauri build --target aarch64-unknown-linux-gnu + - name: Collect artifacts + run: | + mkdir -p artifacts + find src-tauri/target/aarch64-unknown-linux-gnu/release/bundle \ + \( -name "*.deb" -o -name "*.rpm" -o -name "*.AppImage" \) \ + -exec cp {} artifacts/ \; + - uses: actions/upload-artifact@v4 + with: + name: linux-arm64 + path: artifacts/ + + upload-release: + needs: [build-linux-amd64, build-windows-amd64, build-linux-arm64] + runs-on: linux-amd64 + steps: + - uses: actions/download-artifact@v4 + with: + path: artifacts/ + + - name: Create Gitea release and upload artifacts + env: + RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} + run: | + TAG="${{ gitea.ref_name }}" + REPO="${{ gitea.repository }}" + API="http://gitea_app:3000/api/v1" + + # Create release (idempotent) + curl -sf -X POST "$API/repos/$REPO/releases" \ + -H "Authorization: token $RELEASE_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\":\"$TAG\",\"name\":\"TFTSR $TAG\",\"body\":\"Release $TAG\",\"draft\":false}" || true + + # Get release ID + RELEASE_ID=$(curl -sf "$API/repos/$REPO/releases/tags/$TAG" \ + -H "Authorization: token $RELEASE_TOKEN" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) + echo "Release ID: $RELEASE_ID" + + # Upload all artifacts + find artifacts/ -type f | while read f; do + echo "Uploading $f..." + curl -sf -X POST "$API/repos/$REPO/releases/$RELEASE_ID/assets" \ + -H "Authorization: token $RELEASE_TOKEN" \ + -F "attachment=@$f;filename=$(basename $f)" && echo "OK" || echo "Upload failed: $f" + done diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml new file mode 100644 index 00000000..ab8a0141 --- /dev/null +++ b/.gitea/workflows/test.yml @@ -0,0 +1,50 @@ +name: Test + +on: [push, pull_request] + +jobs: + rust-fmt-check: + runs-on: ubuntu-latest + container: + image: rust:1.88-slim + steps: + - uses: actions/checkout@v4 + - run: rustup component add rustfmt + - run: cargo fmt --manifest-path src-tauri/Cargo.toml --check + + rust-clippy: + runs-on: ubuntu-latest + container: + image: rust:1.88-slim + steps: + - uses: actions/checkout@v4 + - run: apt-get update -qq && apt-get install -y -qq libwebkit2gtk-4.1-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf pkg-config perl + - run: rustup component add clippy + - run: cargo clippy --manifest-path src-tauri/Cargo.toml -- -D warnings + + rust-tests: + runs-on: ubuntu-latest + container: + image: rust:1.88-slim + steps: + - uses: actions/checkout@v4 + - run: apt-get update -qq && apt-get install -y -qq libwebkit2gtk-4.1-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf pkg-config perl + - run: cargo test --manifest-path src-tauri/Cargo.toml + + frontend-typecheck: + runs-on: ubuntu-latest + container: + image: node:22-alpine + steps: + - uses: actions/checkout@v4 + - run: npm ci --legacy-peer-deps + - run: npx tsc --noEmit + + frontend-tests: + runs-on: ubuntu-latest + container: + image: node:22-alpine + steps: + - uses: actions/checkout@v4 + - run: npm ci --legacy-peer-deps + - run: npm run test:run