462 lines
16 KiB
YAML
462 lines
16 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:
|
|
check-version:
|
|
runs-on: linux
|
|
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && !startsWith(github.ref, 'refs/tags/')
|
|
outputs:
|
|
should_release: ${{ steps.check.outputs.should_release }}
|
|
version: ${{ steps.check.outputs.version }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Check if version tag exists
|
|
id: check
|
|
run: |
|
|
VERSION=$(grep -Po '"version":\s*"\K[^"]+' src-tauri/tauri.conf.json | head -1)
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
if git rev-parse "v$VERSION" >/dev/null 2>&1; then
|
|
echo "Tag v$VERSION already exists"
|
|
echo "should_release=false" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "Tag v$VERSION does not exist, will create release"
|
|
echo "should_release=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
build-windows:
|
|
runs-on: windows
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: false
|
|
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: Cache npm dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.npm
|
|
node_modules
|
|
cinny/node_modules
|
|
key: npm-windows-${{ hashFiles('package-lock.json', 'cinny/package-lock.json') }}
|
|
restore-keys: |
|
|
npm-windows-
|
|
|
|
- name: Cache Cargo
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
src-tauri/target
|
|
key: cargo-windows-${{ hashFiles('src-tauri/Cargo.lock') }}
|
|
restore-keys: |
|
|
cargo-windows-
|
|
|
|
- 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: Rename MSI files
|
|
shell: powershell
|
|
run: |
|
|
$msi = Get-ChildItem "src-tauri/target/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 "src-tauri/target/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 "src-tauri/target/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: linux
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Cache npm dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.npm
|
|
node_modules
|
|
cinny/node_modules
|
|
key: npm-linux-${{ hashFiles('package-lock.json', 'cinny/package-lock.json') }}
|
|
restore-keys: |
|
|
npm-linux-
|
|
|
|
- name: Cache Cargo
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
src-tauri/target
|
|
key: cargo-linux-${{ hashFiles('src-tauri/Cargo.lock') }}
|
|
restore-keys: |
|
|
cargo-linux-
|
|
|
|
- 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: Rename Linux packages
|
|
run: |
|
|
# Find and copy each file individually to avoid glob issues
|
|
find src-tauri/target/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 src-tauri/target/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 src-tauri/target/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 src-tauri/target/release/bundle/appimage/*.AppImage.sig 1> /dev/null 2>&1; then
|
|
find src-tauri/target/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
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Cache npm dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.npm
|
|
node_modules
|
|
cinny/node_modules
|
|
key: npm-android-${{ hashFiles('package-lock.json', 'cinny/package-lock.json') }}
|
|
restore-keys: |
|
|
npm-android-
|
|
|
|
- name: Cache Cargo
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
src-tauri/target
|
|
key: cargo-android-${{ hashFiles('src-tauri/Cargo.lock') }}
|
|
restore-keys: |
|
|
cargo-android-
|
|
|
|
- name: Cache Gradle
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
src-tauri/gen/android/.gradle
|
|
key: gradle-${{ hashFiles('src-tauri/gen/android/**/*.gradle*', 'src-tauri/gen/android/gradle-wrapper.properties') }}
|
|
restore-keys: |
|
|
gradle-
|
|
|
|
- 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
|
|
run: |
|
|
$env:PATH = "$env:USERPROFILE\.cargo\bin;$env:PATH"
|
|
npm run tauri android build -- --ci --target aarch64
|
|
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: linux
|
|
needs: [check-version, build-windows, build-linux, build-android]
|
|
if: needs.check-version.outputs.should_release == 'true'
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Create and push tag
|
|
run: |
|
|
git config user.name "GitHub Actions"
|
|
git config user.email "actions@github.com"
|
|
git tag -a "v${{ needs.check-version.outputs.version }}" -m "Release v${{ needs.check-version.outputs.version }}"
|
|
git push origin "v${{ needs.check-version.outputs.version }}"
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Get version
|
|
id: version
|
|
run: echo "VERSION=${{ needs.check-version.outputs.version }}" >> $GITHUB_OUTPUT
|
|
|
|
- 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
|
|
# Move artifacts out of subdirectories
|
|
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 Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
tag_name: v${{ needs.check-version.outputs.version }}
|
|
files: release-files/*
|
|
draft: false
|
|
prerelease: false
|
|
generate_release_notes: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|