- Add rpm to bundle targets and install rpm on Linux CI - Upload both .deb and .rpm from Linux build - Install 7-Zip via choco if not already available on Windows runner Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
400 lines
14 KiB
YAML
400 lines
14 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
bump-version:
|
|
name: Bump version and tag
|
|
# Skip if this is a version-bump commit (avoid infinite loop)
|
|
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
new_version: ${{ steps.bump.outputs.new_version }}
|
|
tag: ${{ steps.bump.outputs.tag }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Configure git
|
|
run: |
|
|
git config user.name "Gitea Actions"
|
|
git config user.email "actions@gitea.local"
|
|
|
|
- name: Bump patch version
|
|
id: bump
|
|
run: |
|
|
# Read current version from package.json
|
|
CURRENT=$(grep '"version"' package.json | head -1 | sed 's/.*"version": *"\([^"]*\)".*/\1/')
|
|
echo "Current version: ${CURRENT}"
|
|
|
|
# Increment patch number
|
|
MAJOR=$(echo "${CURRENT}" | cut -d. -f1)
|
|
MINOR=$(echo "${CURRENT}" | cut -d. -f2)
|
|
PATCH=$(echo "${CURRENT}" | cut -d. -f3)
|
|
NEW_PATCH=$((PATCH + 1))
|
|
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
|
|
echo "New version: ${NEW_VERSION}"
|
|
|
|
# Update package.json
|
|
sed -i "s/\"version\": \"${CURRENT}\"/\"version\": \"${NEW_VERSION}\"/" package.json
|
|
|
|
# Update src-tauri/tauri.conf.json
|
|
sed -i "s/\"version\": \"${CURRENT}\"/\"version\": \"${NEW_VERSION}\"/" src-tauri/tauri.conf.json
|
|
|
|
# Update src-tauri/Cargo.toml (match version = "x.y.z" in [package] section)
|
|
sed -i "s/^version = \"${CURRENT}\"/version = \"${NEW_VERSION}\"/" src-tauri/Cargo.toml
|
|
|
|
# Update python/pyproject.toml
|
|
sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" python/pyproject.toml
|
|
|
|
echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT
|
|
echo "tag=v${NEW_VERSION}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Commit and tag
|
|
env:
|
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
|
run: |
|
|
NEW_VERSION="${{ steps.bump.outputs.new_version }}"
|
|
git add package.json src-tauri/tauri.conf.json src-tauri/Cargo.toml python/pyproject.toml
|
|
git commit -m "chore: bump version to ${NEW_VERSION} [skip ci]"
|
|
git tag "v${NEW_VERSION}"
|
|
|
|
# Push using token for authentication
|
|
REMOTE_URL=$(git remote get-url origin | sed "s|://|://gitea-actions:${BUILD_TOKEN}@|")
|
|
git push "${REMOTE_URL}" HEAD:main
|
|
git push "${REMOTE_URL}" "v${NEW_VERSION}"
|
|
|
|
- name: Create Gitea release
|
|
env:
|
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
|
run: |
|
|
REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
|
TAG="${{ steps.bump.outputs.tag }}"
|
|
RELEASE_NAME="Voice to Notes ${TAG}"
|
|
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${BUILD_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"${TAG}\", \"name\": \"${RELEASE_NAME}\", \"body\": \"Automated build.\", \"draft\": false, \"prerelease\": false}" \
|
|
"${REPO_API}/releases"
|
|
echo "Created release: ${RELEASE_NAME}"
|
|
|
|
# ── Platform builds (run after version bump) ──
|
|
|
|
build-linux:
|
|
name: Build (Linux)
|
|
needs: bump-version
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
PYTHON_VERSION: "3.11"
|
|
NODE_VERSION: "20"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ needs.bump-version.outputs.tag }}
|
|
|
|
# ── Python sidecar ──
|
|
- name: Install uv
|
|
run: |
|
|
if command -v uv &> /dev/null; then
|
|
echo "uv already installed: $(uv --version)"
|
|
else
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
fi
|
|
|
|
- name: Install ffmpeg
|
|
run: sudo apt-get update && sudo apt-get install -y ffmpeg
|
|
|
|
- name: Set up Python
|
|
run: uv python install ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Build sidecar
|
|
working-directory: python
|
|
run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --with-cuda
|
|
|
|
- name: Package sidecar for Tauri
|
|
run: |
|
|
cd python/dist/voice-to-notes-sidecar && zip -r ../../../src-tauri/sidecar.zip .
|
|
|
|
# ── Tauri app ──
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Install Rust stable
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
|
|
- name: Install system dependencies
|
|
run: |
|
|
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils rpm
|
|
|
|
- name: Install npm dependencies
|
|
run: npm ci
|
|
|
|
- name: Build Tauri app
|
|
run: npm run tauri build
|
|
|
|
# ── Release ──
|
|
- name: Upload to release
|
|
env:
|
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
|
run: |
|
|
sudo apt-get install -y jq
|
|
REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
|
|
|
TAG="${{ needs.bump-version.outputs.tag }}"
|
|
RELEASE_NAME="Voice to Notes ${TAG}"
|
|
echo "Release tag: ${TAG}"
|
|
|
|
RELEASE_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \
|
|
"${REPO_API}/releases/tags/${TAG}" | jq -r '.id // empty')
|
|
|
|
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
|
|
echo "ERROR: Failed to find release for tag ${TAG}."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Release ID: ${RELEASE_ID}"
|
|
|
|
find src-tauri/target/release/bundle -type f \( -name "*.deb" -o -name "*.rpm" \) | while IFS= read -r file; do
|
|
filename=$(basename "$file")
|
|
encoded_name=$(echo "$filename" | sed 's/ /%20/g')
|
|
echo "Uploading ${filename} ($(du -h "$file" | cut -f1))..."
|
|
|
|
ASSET_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \
|
|
"${REPO_API}/releases/${RELEASE_ID}/assets" | jq -r ".[] | select(.name == \"${filename}\") | .id // empty")
|
|
if [ -n "${ASSET_ID}" ]; then
|
|
curl -s -X DELETE -H "Authorization: token ${BUILD_TOKEN}" \
|
|
"${REPO_API}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
|
|
fi
|
|
|
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
|
|
-H "Authorization: token ${BUILD_TOKEN}" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
-T "$file" \
|
|
"${REPO_API}/releases/${RELEASE_ID}/assets?name=${encoded_name}")
|
|
echo "Upload response: HTTP ${HTTP_CODE}"
|
|
done
|
|
|
|
build-windows:
|
|
name: Build (Windows)
|
|
needs: bump-version
|
|
runs-on: windows-latest
|
|
env:
|
|
PYTHON_VERSION: "3.11"
|
|
NODE_VERSION: "20"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ needs.bump-version.outputs.tag }}
|
|
|
|
# ── Python sidecar ──
|
|
- name: Install uv
|
|
shell: powershell
|
|
run: |
|
|
if (Get-Command uv -ErrorAction SilentlyContinue) {
|
|
Write-Host "uv already installed: $(uv --version)"
|
|
} else {
|
|
irm https://astral.sh/uv/install.ps1 | iex
|
|
echo "$env:USERPROFILE\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
}
|
|
|
|
- name: Install ffmpeg
|
|
shell: powershell
|
|
run: choco install ffmpeg -y
|
|
|
|
- name: Set up Python
|
|
shell: powershell
|
|
run: uv python install ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Build sidecar
|
|
shell: powershell
|
|
working-directory: python
|
|
run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --with-cuda
|
|
|
|
- name: Package sidecar for Tauri
|
|
shell: powershell
|
|
run: |
|
|
# Compress-Archive has a 2GB limit; use 7z for CUDA builds
|
|
if (-not (Get-Command 7z -ErrorAction SilentlyContinue)) {
|
|
choco install 7zip -y
|
|
}
|
|
7z a -tzip -mx=5 src-tauri\sidecar.zip .\python\dist\voice-to-notes-sidecar\*
|
|
|
|
# ── Tauri app ──
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Install Rust stable
|
|
shell: powershell
|
|
run: |
|
|
if (Get-Command rustup -ErrorAction SilentlyContinue) {
|
|
rustup default stable
|
|
} else {
|
|
Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
|
|
.\rustup-init.exe -y --default-toolchain stable
|
|
echo "$env:USERPROFILE\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
}
|
|
|
|
- name: Install npm dependencies
|
|
shell: powershell
|
|
run: npm ci
|
|
|
|
- name: Build Tauri app
|
|
shell: powershell
|
|
run: npm run tauri build
|
|
|
|
# ── Release ──
|
|
- name: Upload to release
|
|
shell: powershell
|
|
env:
|
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
|
run: |
|
|
$REPO_API = "${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
|
|
$Headers = @{ "Authorization" = "token $env:BUILD_TOKEN" }
|
|
|
|
$TAG = "${{ needs.bump-version.outputs.tag }}"
|
|
$RELEASE_NAME = "Voice to Notes ${TAG}"
|
|
Write-Host "Release tag: ${TAG}"
|
|
|
|
$release = Invoke-RestMethod -Uri "${REPO_API}/releases/tags/${TAG}" -Headers $Headers -ErrorAction Stop
|
|
$RELEASE_ID = $release.id
|
|
Write-Host "Release ID: ${RELEASE_ID}"
|
|
|
|
Get-ChildItem -Path src-tauri\target\release\bundle -Recurse -Include *.msi | ForEach-Object {
|
|
$filename = $_.Name
|
|
$encodedName = [System.Uri]::EscapeDataString($filename)
|
|
$size = [math]::Round($_.Length / 1MB, 1)
|
|
Write-Host "Uploading ${filename} (${size} MB)..."
|
|
|
|
try {
|
|
$assets = Invoke-RestMethod -Uri "${REPO_API}/releases/${RELEASE_ID}/assets" -Headers $Headers
|
|
$existing = $assets | Where-Object { $_.name -eq $filename }
|
|
if ($existing) {
|
|
Invoke-RestMethod -Uri "${REPO_API}/releases/${RELEASE_ID}/assets/$($existing.id)" -Method Delete -Headers $Headers
|
|
}
|
|
} catch {}
|
|
|
|
# Use curl for streaming upload (Invoke-RestMethod fails on large files)
|
|
$uploadUrl = "${REPO_API}/releases/${RELEASE_ID}/assets?name=${encodedName}"
|
|
$result = curl.exe --fail --silent --show-error `
|
|
-X POST `
|
|
-H "Authorization: token $env:BUILD_TOKEN" `
|
|
-H "Content-Type: application/octet-stream" `
|
|
-T "$($_.FullName)" `
|
|
"$uploadUrl" 2>&1
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "Upload successful: ${filename}"
|
|
} else {
|
|
Write-Host "WARNING: Upload failed for ${filename}: ${result}"
|
|
}
|
|
}
|
|
|
|
build-macos:
|
|
name: Build (macOS)
|
|
needs: bump-version
|
|
runs-on: macos-latest
|
|
env:
|
|
PYTHON_VERSION: "3.11"
|
|
NODE_VERSION: "20"
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ needs.bump-version.outputs.tag }}
|
|
|
|
# ── Python sidecar ──
|
|
- name: Install uv
|
|
run: |
|
|
if command -v uv &> /dev/null; then
|
|
echo "uv already installed: $(uv --version)"
|
|
else
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
fi
|
|
|
|
- name: Install ffmpeg
|
|
run: brew install ffmpeg
|
|
|
|
- name: Set up Python
|
|
run: uv python install ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Build sidecar
|
|
working-directory: python
|
|
run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --cpu-only
|
|
|
|
- name: Package sidecar for Tauri
|
|
run: |
|
|
cd python/dist/voice-to-notes-sidecar && zip -r ../../../src-tauri/sidecar.zip .
|
|
|
|
# ── Tauri app ──
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
|
|
- name: Install Rust stable
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
|
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
|
|
- name: Install system dependencies
|
|
run: brew install --quiet create-dmg || true
|
|
|
|
- name: Install npm dependencies
|
|
run: npm ci
|
|
|
|
- name: Build Tauri app
|
|
run: npm run tauri build
|
|
|
|
# ── Release ──
|
|
- name: Upload to release
|
|
env:
|
|
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
|
|
run: |
|
|
which jq || brew install jq
|
|
|
|
REPO_API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
|
|
|
TAG="${{ needs.bump-version.outputs.tag }}"
|
|
RELEASE_NAME="Voice to Notes ${TAG}"
|
|
echo "Release tag: ${TAG}"
|
|
|
|
RELEASE_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \
|
|
"${REPO_API}/releases/tags/${TAG}" | jq -r '.id // empty')
|
|
|
|
if [ -z "${RELEASE_ID}" ] || [ "${RELEASE_ID}" = "null" ]; then
|
|
echo "ERROR: Failed to find release for tag ${TAG}."
|
|
exit 1
|
|
fi
|
|
|
|
echo "Release ID: ${RELEASE_ID}"
|
|
|
|
find src-tauri/target/release/bundle -type f -name "*.dmg" | while IFS= read -r file; do
|
|
filename=$(basename "$file")
|
|
encoded_name=$(echo "$filename" | sed 's/ /%20/g')
|
|
echo "Uploading ${filename} ($(du -h "$file" | cut -f1))..."
|
|
|
|
ASSET_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \
|
|
"${REPO_API}/releases/${RELEASE_ID}/assets" | jq -r ".[] | select(.name == \"${filename}\") | .id // empty")
|
|
if [ -n "${ASSET_ID}" ]; then
|
|
curl -s -X DELETE -H "Authorization: token ${BUILD_TOKEN}" \
|
|
"${REPO_API}/releases/${RELEASE_ID}/assets/${ASSET_ID}"
|
|
fi
|
|
|
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
|
|
-H "Authorization: token ${BUILD_TOKEN}" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
-T "$file" \
|
|
"${REPO_API}/releases/${RELEASE_ID}/assets?name=${encoded_name}")
|
|
echo "Upload response: HTTP ${HTTP_CODE}"
|
|
done
|