mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-14 06:07:23 -05:00
338 lines
8.5 KiB
YAML
338 lines
8.5 KiB
YAML
stages:
|
|
- build
|
|
- release
|
|
|
|
build:
|
|
stage: build
|
|
tags:
|
|
- saas-windows-medium-amd64
|
|
|
|
rules:
|
|
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
|
- if: '$CI_PIPELINE_SOURCE == "web"'
|
|
- if: '$CI_COMMIT_BRANCH == "main"'
|
|
changes:
|
|
- build-pipeline.js
|
|
- package.json
|
|
- config/**/*
|
|
- src-tauri/**/*
|
|
- service-manager.js
|
|
- patcher.js
|
|
- credential-manager.js
|
|
- crypto-utils.js
|
|
- update-client.js
|
|
- .gitlab-ci.yml
|
|
|
|
variables:
|
|
GITLAB_TOKEN: $VYLA_GITLAB_TOKEN
|
|
PLAYER_TMDB_KEY: $TMDB_KEY
|
|
PLAYER_API_KEY: $API_KEY
|
|
STREAM_API_TMDB_API_KEY: $TMDB_API_KEY
|
|
STREAM_API_GA_API_SECRET: $GA_API_SECRET
|
|
STREAM_API_GA_MEASUREMENT_ID: $GA_MEASUREMENT_ID
|
|
STREAM_API_TOKEN_SECRET: $TOKEN_SECRET
|
|
PLAYER_BASE_URL: $BASE_URL
|
|
STREAM_API_PROXY_URL: $PROXY_URL
|
|
STREAM_API_PROXY_STREAMS: $PROXY_STREAMS
|
|
STREAM_API_ENABLE_DEBUG_ROUTE: $ENABLE_DEBUG_ROUTE
|
|
PLAYER_BYPASS_AUTH: $BYPASS_AUTH
|
|
STREAM_API_BYPASS_AUTH: $BYPASS_AUTH
|
|
AUTH_PROXY_VITE_BASE_URL: $AUTH_PROXY_BASE_URL
|
|
AUTH_PROXY_VITE_API_KEY: $AUTH_PROXY_API_KEY
|
|
AUTH_PROXY_DEV_BYPASS_AUTH: $DEV_BYPASS_AUTH
|
|
AUTH_PROXY_PROXY_VITE_API_KEY: $PROXY_VITE_API_KEY
|
|
|
|
GIT_TERMINAL_PROMPT: "0"
|
|
|
|
CARGO_HOME: "$CI_PROJECT_DIR/.cargo"
|
|
|
|
cache:
|
|
key:
|
|
files:
|
|
- package-lock.json
|
|
- src-tauri/Cargo.lock
|
|
paths:
|
|
- .cargo/
|
|
- src-tauri/target/
|
|
policy: pull-push
|
|
|
|
script:
|
|
- npm ci
|
|
|
|
- |
|
|
$repos = @("frontend", "player", "stream-api", "auth-proxy")
|
|
$last = @{}
|
|
|
|
if (Test-Path "last-shas.json") {
|
|
$rawJson = Get-Content "last-shas.json" -Raw | ConvertFrom-Json
|
|
|
|
if ($rawJson) {
|
|
$rawJson.psobject.properties | ForEach-Object {
|
|
$last[$_.Name] = $_.Value
|
|
}
|
|
}
|
|
}
|
|
|
|
$current = @{}
|
|
$changed = $false
|
|
|
|
foreach ($repo in $repos) {
|
|
$headers = @{
|
|
"PRIVATE-TOKEN" = "$env:GITLAB_TOKEN"
|
|
}
|
|
|
|
$uri = "https://gitlab.com/api/v4/projects/vyla-entertainment%2F$repo/repository/commits/main"
|
|
|
|
try {
|
|
$resp = Invoke-RestMethod -Uri $uri -Headers $headers
|
|
$sha = $resp.id
|
|
$current[$repo] = $sha
|
|
|
|
if (-not $last.ContainsKey($repo) -or $last[$repo] -ne $sha) {
|
|
Write-Host "Change detected in $repo (main): $sha"
|
|
$changed = $true
|
|
}
|
|
else {
|
|
Write-Host "No change in $repo (main)"
|
|
}
|
|
}
|
|
catch {
|
|
Write-Warning "Failed to fetch commit info for $repo."
|
|
}
|
|
}
|
|
|
|
$current | ConvertTo-Json | Set-Content last-shas.json
|
|
|
|
if ($env:CI_PIPELINE_SOURCE -ne "schedule") {
|
|
$changed = $true
|
|
}
|
|
|
|
if (-not $changed) {
|
|
Write-Host "No changes detected. Skipping build."
|
|
exit 0
|
|
}
|
|
|
|
- Write-Host "Starting secure build process..."
|
|
- node build-pipeline.js
|
|
|
|
- |
|
|
if (Test-Path "update-payload.zip") {
|
|
Write-Host "Build artifact verified: update-payload.zip exists"
|
|
|
|
$size = (Get-Item update-payload.zip).Length
|
|
|
|
Write-Host " Size: $size bytes"
|
|
}
|
|
else {
|
|
Write-Error "Build artifact missing: update-payload.zip"
|
|
exit 1
|
|
}
|
|
|
|
if (Test-Path "manifest.json") {
|
|
Write-Host "Manifest file verified"
|
|
|
|
Get-Content manifest.json |
|
|
ConvertFrom-Json |
|
|
ConvertTo-Json -Depth 10
|
|
}
|
|
else {
|
|
Write-Error "Manifest file missing"
|
|
exit 1
|
|
}
|
|
|
|
if (Test-Path "validation-report.json") {
|
|
Write-Host "Validation report verified"
|
|
}
|
|
|
|
- Write-Host "Setting up Rust toolchain..."
|
|
- |
|
|
if (-not (Get-Command rustup -ErrorAction SilentlyContinue)) {
|
|
Invoke-WebRequest `
|
|
-Uri "https://win.rustup.rs/x86_64" `
|
|
-OutFile "rustup-init.exe"
|
|
|
|
.\rustup-init.exe -y --default-toolchain stable
|
|
|
|
Remove-Item "rustup-init.exe"
|
|
}
|
|
|
|
$env:Path = "$env:USERPROFILE\.cargo\bin;" + $env:Path
|
|
|
|
rustup default stable
|
|
rustc --version
|
|
cargo --version
|
|
|
|
- Write-Host "Packaging Tauri application..."
|
|
- npm run build
|
|
|
|
- |
|
|
Write-Host "Verifying Windows installers..."
|
|
|
|
$nsisDir = "src-tauri/target/release/bundle/nsis"
|
|
$msiDir = "src-tauri/target/release/bundle/msi"
|
|
|
|
$nsisFiles = @(Get-ChildItem "$nsisDir/*.exe" -ErrorAction SilentlyContinue)
|
|
$msiFiles = @(Get-ChildItem "$msiDir/*.msi" -ErrorAction SilentlyContinue)
|
|
|
|
if ($nsisFiles.Count -eq 0) {
|
|
Write-Error "No NSIS installer was found."
|
|
exit 1
|
|
}
|
|
|
|
if ($msiFiles.Count -eq 0) {
|
|
Write-Error "No MSI installer was found."
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "NSIS installer:"
|
|
$nsisFiles | ForEach-Object {
|
|
Write-Host " $($_.FullName)"
|
|
Write-Host " Size: $($_.Length) bytes"
|
|
}
|
|
|
|
Write-Host "MSI installer:"
|
|
$msiFiles | ForEach-Object {
|
|
Write-Host " $($_.FullName)"
|
|
Write-Host " Size: $($_.Length) bytes"
|
|
}
|
|
|
|
- |
|
|
Write-Host "Saving build job information..."
|
|
|
|
@"
|
|
BUILD_JOB_ID=$env:CI_JOB_ID
|
|
BUILD_PIPELINE_ID=$env:CI_PIPELINE_ID
|
|
BUILD_PIPELINE_IID=$env:CI_PIPELINE_IID
|
|
BUILD_COMMIT_SHA=$env:CI_COMMIT_SHA
|
|
"@ | Set-Content build-info.env
|
|
|
|
Write-Host "Build job ID: $env:CI_JOB_ID"
|
|
Write-Host "Pipeline IID: $env:CI_PIPELINE_IID"
|
|
|
|
artifacts:
|
|
paths:
|
|
- update-payload.zip
|
|
- manifest.json
|
|
- validation-report.json
|
|
- build-info.env
|
|
- src-tauri/target/release/bundle/nsis/*.exe
|
|
- src-tauri/target/release/bundle/msi/*.msi
|
|
reports:
|
|
dotenv: build-info.env
|
|
expire_in: 30 days
|
|
|
|
|
|
release:
|
|
stage: release
|
|
tags:
|
|
- saas-windows-medium-amd64
|
|
|
|
needs:
|
|
- job: build
|
|
artifacts: true
|
|
|
|
rules:
|
|
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
|
- if: '$CI_PIPELINE_SOURCE == "web"'
|
|
- if: '$CI_COMMIT_BRANCH == "main"'
|
|
|
|
script:
|
|
- |
|
|
Write-Host "Publishing Release to GitLab..."
|
|
|
|
if (-not $env:BUILD_JOB_ID) {
|
|
Write-Error "BUILD_JOB_ID is missing."
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "Build job ID: $env:BUILD_JOB_ID"
|
|
|
|
$versionTag = "v$env:CI_PIPELINE_IID"
|
|
|
|
$exeItem = Get-ChildItem `
|
|
"src-tauri/target/release/bundle/nsis/*.exe" `
|
|
-ErrorAction SilentlyContinue |
|
|
Select-Object -First 1
|
|
|
|
if (-not $exeItem) {
|
|
Write-Error "No Windows NSIS installer was found in downloaded build artifacts."
|
|
exit 1
|
|
}
|
|
|
|
$exeName = $exeItem.Name
|
|
$exeEncoded = [System.Uri]::EscapeDataString($exeName)
|
|
|
|
Write-Host "Installer: $exeName"
|
|
|
|
$artifactBaseUrl = "$env:CI_PROJECT_URL/-/jobs/$env:BUILD_JOB_ID/artifacts/raw"
|
|
|
|
$exeUrl = "$artifactBaseUrl/src-tauri/target/release/bundle/nsis/$exeEncoded"
|
|
$payloadUrl = "$artifactBaseUrl/update-payload.zip"
|
|
$manifestUrl = "$artifactBaseUrl/manifest.json"
|
|
|
|
Write-Host "Installer URL: $exeUrl"
|
|
Write-Host "Payload URL: $payloadUrl"
|
|
Write-Host "Manifest URL: $manifestUrl"
|
|
|
|
$releaseBody = @{
|
|
name = "Vyla Home Release $versionTag"
|
|
|
|
tag_name = "$versionTag"
|
|
|
|
description = @"
|
|
Automated release for build $versionTag.
|
|
|
|
Windows installer:
|
|
$exeName
|
|
|
|
Build job:
|
|
$env:BUILD_JOB_ID
|
|
"@
|
|
|
|
ref = "$env:CI_COMMIT_SHA"
|
|
|
|
assets = @{
|
|
links = @(
|
|
@{
|
|
name = "$exeName"
|
|
url = "$exeUrl"
|
|
link_type = "package"
|
|
},
|
|
@{
|
|
name = "update-payload.zip"
|
|
url = "$payloadUrl"
|
|
link_type = "other"
|
|
},
|
|
@{
|
|
name = "manifest.json"
|
|
url = "$manifestUrl"
|
|
link_type = "other"
|
|
}
|
|
)
|
|
}
|
|
} | ConvertTo-Json -Depth 10
|
|
|
|
$releaseHeaders = @{
|
|
"JOB-TOKEN" = "$env:CI_JOB_TOKEN"
|
|
"Content-Type" = "application/json"
|
|
}
|
|
|
|
try {
|
|
$createdRelease = Invoke-RestMethod `
|
|
-Uri "https://gitlab.com/api/v4/projects/$env:CI_PROJECT_ID/releases" `
|
|
-Method Post `
|
|
-Headers $releaseHeaders `
|
|
-Body $releaseBody
|
|
|
|
Write-Host "Release successfully published: $($createdRelease.tag_name)"
|
|
Write-Host "Release URL: $($createdRelease._links.self)"
|
|
}
|
|
catch {
|
|
Write-Error "Release creation failed: $($_.Exception.Message)"
|
|
|
|
if ($_.ErrorDetails.Message) {
|
|
Write-Error $_.ErrorDetails.Message
|
|
}
|
|
|
|
exit 1
|
|
} |