Files
cinny-desktop/.gitea/workflows/build.yml
Max Litruv Boonzaayer ce3c236e2e
All checks were successful
Build / build-windows (push) Successful in 4m20s
Build / build-linux (push) Successful in 10m41s
Build / build-android (push) Successful in 11m31s
Build / create-release (push) Successful in 12s
feat: implement create or update release functionality in build workflow
2026-02-19 19:32:17 +11:00

440 lines
17 KiB
YAML

name: Build
on:
push:
branches:
- main
- dev
tags:
- 'v*'
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
CARGO_INCREMENTAL: 1
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10
jobs:
build-windows:
runs-on: windows
env:
CARGO_TARGET_DIR: C:\cargo-cache\cinny-desktop
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
ref: ${{ github.ref_name }}
clean: false
- name: Checkout submodules (Windows workaround)
shell: powershell
run: |
git submodule update --init --recursive
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install dependencies (root)
run: npm install --prefer-offline
- name: Install dependencies (cinny)
working-directory: ./cinny
run: npm install --prefer-offline
- name: Build Tauri app
run: npm run tauri build
- name: Copy and rename MSI files
shell: powershell
run: |
# Ensure output dir exists in workspace
New-Item -ItemType Directory -Force -Path "src-tauri/target/release/bundle/msi" | Out-Null
# Copy from persistent cache location
$msi = Get-ChildItem "$env:CARGO_TARGET_DIR/release/bundle/msi/*.msi" -Exclude "Cinny-*" | Select-Object -First 1
Copy-Item $msi.FullName "src-tauri/target/release/bundle/msi/Cinny-Windows-x64.msi"
$msiZip = Get-ChildItem "$env:CARGO_TARGET_DIR/release/bundle/msi/*.msi.zip" -Exclude "Cinny-*" | Select-Object -First 1
if ($msiZip) { Copy-Item $msiZip.FullName "src-tauri/target/release/bundle/msi/Cinny-Windows-x64.msi.zip" }
$msiZipSig = Get-ChildItem "$env:CARGO_TARGET_DIR/release/bundle/msi/*.msi.zip.sig" -Exclude "Cinny-*" | Select-Object -First 1
if ($msiZipSig) { Copy-Item $msiZipSig.FullName "src-tauri/target/release/bundle/msi/Cinny-Windows-x64.msi.zip.sig" }
Get-ChildItem "src-tauri/target/release/bundle/msi/"
- name: Upload MSI installer
uses: actions/upload-artifact@v3
with:
name: Cinny-Windows-x64.msi
path: src-tauri/target/release/bundle/msi/Cinny-Windows-x64.msi
- name: Upload MSI updater zip
uses: actions/upload-artifact@v3
if: always()
with:
name: Cinny-Windows-x64.msi.zip
path: src-tauri/target/release/bundle/msi/Cinny-Windows-x64.msi.zip
- name: Upload MSI updater signature
uses: actions/upload-artifact@v3
if: always()
with:
name: Cinny-Windows-x64.msi.zip.sig
path: src-tauri/target/release/bundle/msi/Cinny-Windows-x64.msi.zip.sig
build-linux:
runs-on: ubuntu-latest
env:
CARGO_TARGET_DIR: /home/runner/cargo-cache/cinny-desktop
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
ref: ${{ github.ref_name }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev rpm patchelf xdg-utils
- name: Install dependencies (root)
run: npm ci --prefer-offline
- name: Install dependencies (cinny)
working-directory: ./cinny
run: npm ci --prefer-offline
- name: Build Tauri app
run: npm run tauri build
- name: Copy and rename Linux packages
run: |
# Create workspace output directories
mkdir -p src-tauri/target/release/bundle/appimage
mkdir -p src-tauri/target/release/bundle/deb
mkdir -p src-tauri/target/release/bundle/rpm
# Copy from persistent cache location
find $CARGO_TARGET_DIR/release/bundle/appimage -name "*.AppImage" -not -name "Cinny-Linux*" | head -1 | xargs -I {} cp {} src-tauri/target/release/bundle/appimage/Cinny-Linux-x64.AppImage
find $CARGO_TARGET_DIR/release/bundle/deb -name "*.deb" -not -name "Cinny-Linux*" | head -1 | xargs -I {} cp {} src-tauri/target/release/bundle/deb/Cinny-Linux-x64.deb
find $CARGO_TARGET_DIR/release/bundle/rpm -name "*.rpm" -not -name "Cinny-Linux*" | head -1 | xargs -I {} cp {} src-tauri/target/release/bundle/rpm/Cinny-Linux-x64.rpm
# Copy signature file for updater if it exists
if ls $CARGO_TARGET_DIR/release/bundle/appimage/*.AppImage.sig 1> /dev/null 2>&1; then
find $CARGO_TARGET_DIR/release/bundle/appimage -name "*.AppImage.sig" -not -name "Cinny-Linux*" | head -1 | xargs -I {} cp {} src-tauri/target/release/bundle/appimage/Cinny-Linux-x64.AppImage.sig
fi
# List what we have
ls -la src-tauri/target/release/bundle/appimage/
ls -la src-tauri/target/release/bundle/deb/
ls -la src-tauri/target/release/bundle/rpm/
- name: Upload AppImage
uses: actions/upload-artifact@v3
with:
name: Cinny-Linux-x64.AppImage
path: src-tauri/target/release/bundle/appimage/Cinny-Linux-x64.AppImage
- name: Upload AppImage Signature
uses: actions/upload-artifact@v3
if: always()
with:
name: Cinny-Linux-x64.AppImage.sig
path: src-tauri/target/release/bundle/appimage/Cinny-Linux-x64.AppImage.sig
- name: Upload DEB package
uses: actions/upload-artifact@v3
with:
name: Cinny-Linux-x64.deb
path: src-tauri/target/release/bundle/deb/Cinny-Linux-x64.deb
- name: Upload RPM package
uses: actions/upload-artifact@v3
with:
name: Cinny-Linux-x64.rpm
path: src-tauri/target/release/bundle/rpm/Cinny-Linux-x64.rpm
build-android:
runs-on: windows
env:
CARGO_TARGET_DIR: C:\cargo-cache\cinny-desktop-android
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
ref: ${{ github.ref_name }}
clean: false
- name: Checkout submodules (Windows workaround)
shell: powershell
run: |
git submodule update --init --recursive
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: aarch64-linux-android
- name: Add Android targets
run: |
rustup target add aarch64-linux-android --toolchain stable
- name: Install dependencies (root)
run: npm ci --prefer-offline
- name: Install dependencies (cinny)
working-directory: ./cinny
run: npm ci --prefer-offline
- name: Build Android APK
shell: powershell
timeout-minutes: 30
run: |
$env:PATH = "$env:USERPROFILE\.cargo\bin;$env:PATH"
npm run tauri android build -- --ci --target aarch64
# Kill any lingering processes that might hang
Stop-Process -Name "java" -Force -ErrorAction SilentlyContinue
Stop-Process -Name "gradle" -Force -ErrorAction SilentlyContinue
env:
ANDROID_HOME: ${{ env.ANDROID_HOME }}
NDK_HOME: ${{ env.ANDROID_HOME }}/ndk/25.2.9519653
RUSTUP_TOOLCHAIN: stable
CI: true
- name: Sign APK
shell: powershell
run: |
$unsignedApk = "src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-unsigned.apk"
$signedApk = "src-tauri/gen/android/app/build/outputs/apk/universal/release/cinny-release.apk"
$keystoreDir = "$env:USERPROFILE\.android"
$keystore = "$keystoreDir\debug.keystore"
# Find Android SDK
$androidHome = if ($env:ANDROID_HOME) { $env:ANDROID_HOME }
elseif ($env:ANDROID_SDK_ROOT) { $env:ANDROID_SDK_ROOT }
elseif (Test-Path "$env:LOCALAPPDATA\Android\Sdk") { "$env:LOCALAPPDATA\Android\Sdk" }
else { "$env:USERPROFILE\AppData\Local\Android\Sdk" }
Write-Host "Using Android SDK at: $androidHome"
# Ensure keystore directory exists
if (-not (Test-Path $keystoreDir)) {
New-Item -ItemType Directory -Path $keystoreDir -Force | Out-Null
}
# Use debug keystore for signing (create if missing)
if (-not (Test-Path $keystore)) {
Write-Host "Creating debug keystore..."
# Use -noprompt to avoid any interactive prompts
& keytool -genkeypair -noprompt -keystore $keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "CN=Android Debug,O=Android,C=US"
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to create keystore"
exit 1
}
}
Write-Host "Using keystore: $keystore"
# Find build tools
$buildTools = Get-ChildItem "$androidHome\build-tools" | Sort-Object Name -Descending | Select-Object -First 1
$apksigner = "$($buildTools.FullName)\apksigner.bat"
$zipalign = "$($buildTools.FullName)\zipalign.exe"
Write-Host "Using build tools: $($buildTools.FullName)"
# Align the APK
Write-Host "Aligning APK..."
& $zipalign -v -p 4 $unsignedApk "$unsignedApk.aligned"
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to align APK"
exit 1
}
# Sign the APK
Write-Host "Signing APK..."
& $apksigner sign --ks $keystore --ks-pass pass:android --key-pass pass:android --out $signedApk "$unsignedApk.aligned"
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to sign APK"
exit 1
}
# Verify
Write-Host "Verifying signature..."
& $apksigner verify $signedApk
Write-Host "Signed APK created at: $signedApk"
# Rename to final name
Copy-Item $signedApk "src-tauri/gen/android/app/build/outputs/apk/universal/release/Cinny-Android.apk"
Write-Host "Done! APK ready at: Cinny-Android.apk"
- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: Cinny-Android.apk
path: src-tauri/gen/android/app/build/outputs/apk/universal/release/Cinny-Android.apk
create-release:
runs-on: ubuntu-latest
needs: [build-windows, build-linux, build-android]
if: always() && (needs.build-windows.result == 'success' || needs.build-linux.result == 'success')
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
id: version
run: |
VERSION=$(grep -Po '"version":\s*"\K[^"]+' src-tauri/tauri.conf.json | head -1)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Check if tag exists
id: tag_check
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
echo "Tag v$VERSION already exists"
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "Tag v$VERSION does not exist"
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Create and push tag
if: steps.tag_check.outputs.exists == 'false'
run: |
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git tag -a "v${{ steps.version.outputs.VERSION }}" -m "Release v${{ steps.version.outputs.VERSION }}"
git push origin "v${{ steps.version.outputs.VERSION }}"
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create update.json
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
APPIMAGE_SIG=""
MSI_SIG=""
if [ -f "artifacts/Cinny-Linux-x64.AppImage.sig/Cinny-Linux-x64.AppImage.sig" ]; then
APPIMAGE_SIG=$(cat "artifacts/Cinny-Linux-x64.AppImage.sig/Cinny-Linux-x64.AppImage.sig")
fi
if [ -f "artifacts/Cinny-Windows-x64.msi.zip.sig/Cinny-Windows-x64.msi.zip.sig" ]; then
MSI_SIG=$(cat "artifacts/Cinny-Windows-x64.msi.zip.sig/Cinny-Windows-x64.msi.zip.sig")
fi
cat > update.json << EOF
{
"version": "${VERSION}",
"notes": "Update to version ${VERSION}",
"pub_date": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"platforms": {
"linux-x86_64": {
"signature": "${APPIMAGE_SIG}",
"url": "http://synbox.ruv.wtf:8418/litruv/cinny-desktop/releases/download/v${VERSION}/Cinny-Linux-x64.AppImage"
},
"windows-x86_64": {
"signature": "${MSI_SIG}",
"url": "http://synbox.ruv.wtf:8418/litruv/cinny-desktop/releases/download/v${VERSION}/Cinny-Windows-x64.msi.zip"
}
}
}
EOF
cat update.json
- name: Prepare release files
run: |
mkdir -p release-files
find artifacts -type f \( -name "*.msi" -o -name "*.msi.zip" -o -name "*.msi.zip.sig" -o -name "*.AppImage" -o -name "*.deb" -o -name "*.rpm" -o -name "*.apk" -o -name "*.sig" \) -exec cp {} release-files/ \;
cp update.json release-files/
ls -la release-files/
- name: Create or Update Release
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
TAG_NAME="v${VERSION}"
API_BASE="http://synbox.ruv.wtf:8418/api/v1"
REPO="litruv/cinny-desktop"
# Check if release exists
RELEASE_ID=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
"${API_BASE}/repos/${REPO}/releases/tags/${TAG_NAME}" | jq -r '.id // empty')
if [ -z "$RELEASE_ID" ]; then
echo "Creating new release for ${TAG_NAME}..."
RELEASE_ID=$(curl -s -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"${TAG_NAME}\", \"name\": \"Release ${TAG_NAME}\", \"body\": \"Release ${VERSION}\", \"draft\": false, \"prerelease\": false}" \
"${API_BASE}/repos/${REPO}/releases" | jq -r '.id')
echo "Created release with ID: ${RELEASE_ID}"
else
echo "Release exists with ID: ${RELEASE_ID}"
# Delete existing assets
echo "Deleting existing assets..."
ASSETS=$(curl -s -H "Authorization: token ${GITEA_TOKEN}" \
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets" | jq -r '.[].id')
for ASSET_ID in $ASSETS; do
echo "Deleting asset ${ASSET_ID}..."
curl -s -X DELETE -H "Authorization: token ${GITEA_TOKEN}" \
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
done
fi
# Upload new assets
echo "Uploading assets..."
for FILE in release-files/*; do
FILENAME=$(basename "$FILE")
echo "Uploading ${FILENAME}..."
curl -s -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@${FILE}" \
"${API_BASE}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}"
echo ""
done
echo "Release complete!"