mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-20 09:07:23 -05:00
release artifact URLs by publishing after build completion
This commit is contained in:
200
.gitlab-ci.yml
200
.gitlab-ci.yml
@@ -1,10 +1,12 @@
|
|||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
- release
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
tags:
|
tags:
|
||||||
- saas-windows-medium-amd64
|
- saas-windows-medium-amd64
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
||||||
- if: '$CI_PIPELINE_SOURCE == "web"'
|
- if: '$CI_PIPELINE_SOURCE == "web"'
|
||||||
@@ -20,6 +22,7 @@ build:
|
|||||||
- crypto-utils.js
|
- crypto-utils.js
|
||||||
- update-client.js
|
- update-client.js
|
||||||
- .gitlab-ci.yml
|
- .gitlab-ci.yml
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
GITLAB_TOKEN: $VYLA_GITLAB_TOKEN
|
GITLAB_TOKEN: $VYLA_GITLAB_TOKEN
|
||||||
PLAYER_TMDB_KEY: $TMDB_KEY
|
PLAYER_TMDB_KEY: $TMDB_KEY
|
||||||
@@ -38,15 +41,21 @@ build:
|
|||||||
AUTH_PROXY_VITE_API_KEY: $AUTH_PROXY_API_KEY
|
AUTH_PROXY_VITE_API_KEY: $AUTH_PROXY_API_KEY
|
||||||
AUTH_PROXY_DEV_BYPASS_AUTH: $DEV_BYPASS_AUTH
|
AUTH_PROXY_DEV_BYPASS_AUTH: $DEV_BYPASS_AUTH
|
||||||
AUTH_PROXY_PROXY_VITE_API_KEY: $PROXY_VITE_API_KEY
|
AUTH_PROXY_PROXY_VITE_API_KEY: $PROXY_VITE_API_KEY
|
||||||
|
|
||||||
GIT_TERMINAL_PROMPT: "0"
|
GIT_TERMINAL_PROMPT: "0"
|
||||||
|
|
||||||
|
CARGO_HOME: "$CI_PROJECT_DIR/.cargo"
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
key:
|
key:
|
||||||
files:
|
files:
|
||||||
- package-lock.json
|
- package-lock.json
|
||||||
- src-tauri/Cargo.lock
|
- src-tauri/Cargo.lock
|
||||||
paths:
|
paths:
|
||||||
- node_modules/
|
- .cargo/
|
||||||
- src-tauri/target/
|
- src-tauri/target/
|
||||||
|
policy: pull-push
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- npm ci
|
- npm ci
|
||||||
|
|
||||||
@@ -56,8 +65,11 @@ build:
|
|||||||
|
|
||||||
if (Test-Path "last-shas.json") {
|
if (Test-Path "last-shas.json") {
|
||||||
$rawJson = Get-Content "last-shas.json" -Raw | ConvertFrom-Json
|
$rawJson = Get-Content "last-shas.json" -Raw | ConvertFrom-Json
|
||||||
|
|
||||||
if ($rawJson) {
|
if ($rawJson) {
|
||||||
$rawJson.psobject.properties | ForEach-Object { $last[$_.Name] = $_.Value }
|
$rawJson.psobject.properties | ForEach-Object {
|
||||||
|
$last[$_.Name] = $_.Value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,10 +91,12 @@ build:
|
|||||||
if (-not $last.ContainsKey($repo) -or $last[$repo] -ne $sha) {
|
if (-not $last.ContainsKey($repo) -or $last[$repo] -ne $sha) {
|
||||||
Write-Host "Change detected in $repo (main): $sha"
|
Write-Host "Change detected in $repo (main): $sha"
|
||||||
$changed = $true
|
$changed = $true
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Write-Host "No change in $repo (main)"
|
Write-Host "No change in $repo (main)"
|
||||||
}
|
}
|
||||||
} catch {
|
}
|
||||||
|
catch {
|
||||||
Write-Warning "Failed to fetch commit info for $repo."
|
Write-Warning "Failed to fetch commit info for $repo."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,17 +118,24 @@ build:
|
|||||||
- |
|
- |
|
||||||
if (Test-Path "update-payload.zip") {
|
if (Test-Path "update-payload.zip") {
|
||||||
Write-Host "Build artifact verified: update-payload.zip exists"
|
Write-Host "Build artifact verified: update-payload.zip exists"
|
||||||
|
|
||||||
$size = (Get-Item update-payload.zip).Length
|
$size = (Get-Item update-payload.zip).Length
|
||||||
|
|
||||||
Write-Host " Size: $size bytes"
|
Write-Host " Size: $size bytes"
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
Write-Error "Build artifact missing: update-payload.zip"
|
Write-Error "Build artifact missing: update-payload.zip"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-Path "manifest.json") {
|
if (Test-Path "manifest.json") {
|
||||||
Write-Host "Manifest file verified"
|
Write-Host "Manifest file verified"
|
||||||
Get-Content manifest.json | ConvertFrom-Json | ConvertTo-Json -Depth 10
|
|
||||||
} else {
|
Get-Content manifest.json |
|
||||||
|
ConvertFrom-Json |
|
||||||
|
ConvertTo-Json -Depth 10
|
||||||
|
}
|
||||||
|
else {
|
||||||
Write-Error "Manifest file missing"
|
Write-Error "Manifest file missing"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@@ -126,48 +147,170 @@ build:
|
|||||||
- Write-Host "Setting up Rust toolchain..."
|
- Write-Host "Setting up Rust toolchain..."
|
||||||
- |
|
- |
|
||||||
if (-not (Get-Command rustup -ErrorAction SilentlyContinue)) {
|
if (-not (Get-Command rustup -ErrorAction SilentlyContinue)) {
|
||||||
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile "rustup-init.exe"
|
Invoke-WebRequest `
|
||||||
|
-Uri "https://win.rustup.rs/x86_64" `
|
||||||
|
-OutFile "rustup-init.exe"
|
||||||
|
|
||||||
.\rustup-init.exe -y --default-toolchain stable
|
.\rustup-init.exe -y --default-toolchain stable
|
||||||
|
|
||||||
Remove-Item "rustup-init.exe"
|
Remove-Item "rustup-init.exe"
|
||||||
}
|
}
|
||||||
|
|
||||||
$env:Path = "$env:USERPROFILE\.cargo\bin;" + $env:Path
|
$env:Path = "$env:USERPROFILE\.cargo\bin;" + $env:Path
|
||||||
|
|
||||||
|
rustup default stable
|
||||||
|
rustc --version
|
||||||
|
cargo --version
|
||||||
|
|
||||||
- Write-Host "Packaging Tauri application..."
|
- Write-Host "Packaging Tauri application..."
|
||||||
- npm run build
|
- 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..."
|
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"
|
$versionTag = "v$env:CI_PIPELINE_IID"
|
||||||
$exeItem = Get-ChildItem src-tauri/target/release/bundle/nsis/*.exe, src-tauri/target/release/bundle/msi/*.msi | Select-Object -First 1
|
|
||||||
|
$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
|
$exeName = $exeItem.Name
|
||||||
$exeEncoded = [System.Uri]::EscapeDataString($exeName)
|
$exeEncoded = [System.Uri]::EscapeDataString($exeName)
|
||||||
$bundleDir = $exeItem.Directory.Name
|
|
||||||
|
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 = @{
|
$releaseBody = @{
|
||||||
name = "Vyla Home Release $versionTag"
|
name = "Vyla Home Release $versionTag"
|
||||||
|
|
||||||
tag_name = "$versionTag"
|
tag_name = "$versionTag"
|
||||||
description = "Automated release for build $versionTag. Download the Windows installer below."
|
|
||||||
|
description = @"
|
||||||
|
Automated release for build $versionTag.
|
||||||
|
|
||||||
|
Windows installer:
|
||||||
|
$exeName
|
||||||
|
|
||||||
|
Build job:
|
||||||
|
$env:BUILD_JOB_ID
|
||||||
|
"@
|
||||||
|
|
||||||
ref = "$env:CI_COMMIT_SHA"
|
ref = "$env:CI_COMMIT_SHA"
|
||||||
|
|
||||||
assets = @{
|
assets = @{
|
||||||
links = @(
|
links = @(
|
||||||
@{
|
@{
|
||||||
name = "$exeName"
|
name = "$exeName"
|
||||||
url = "$env:CI_PROJECT_URL/-/jobs/$env:CI_JOB_ID/artifacts/raw/src-tauri/target/release/bundle/$bundleDir/$exeEncoded"
|
url = "$exeUrl"
|
||||||
link_type = "package"
|
link_type = "package"
|
||||||
},
|
},
|
||||||
@{
|
@{
|
||||||
name = "update-payload.zip"
|
name = "update-payload.zip"
|
||||||
url = "$env:CI_PROJECT_URL/-/jobs/$env:CI_JOB_ID/artifacts/raw/update-payload.zip"
|
url = "$payloadUrl"
|
||||||
link_type = "other"
|
link_type = "other"
|
||||||
},
|
},
|
||||||
@{
|
@{
|
||||||
name = "manifest.json"
|
name = "manifest.json"
|
||||||
url = "$env:CI_PROJECT_URL/-/jobs/$env:CI_JOB_ID/artifacts/raw/manifest.json"
|
url = "$manifestUrl"
|
||||||
link_type = "other"
|
link_type = "other"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} | ConvertTo-Json -Depth 5
|
} | ConvertTo-Json -Depth 10
|
||||||
|
|
||||||
$releaseHeaders = @{
|
$releaseHeaders = @{
|
||||||
"JOB-TOKEN" = "$env:CI_JOB_TOKEN"
|
"JOB-TOKEN" = "$env:CI_JOB_TOKEN"
|
||||||
@@ -175,18 +318,21 @@ build:
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$createdRelease = Invoke-RestMethod -Uri "https://gitlab.com/api/v4/projects/$env:CI_PROJECT_ID/releases" -Method Post -Headers $releaseHeaders -Body $releaseBody
|
$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 successfully published: $($createdRelease.tag_name)"
|
||||||
} catch {
|
Write-Host "Release URL: $($createdRelease._links.self)"
|
||||||
Write-Warning "Release creation failed: $($_.Exception.Message)"
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "Release creation failed: $($_.Exception.Message)"
|
||||||
|
|
||||||
|
if ($_.ErrorDetails.Message) {
|
||||||
|
Write-Error $_.ErrorDetails.Message
|
||||||
|
}
|
||||||
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- update-payload.zip
|
|
||||||
- manifest.json
|
|
||||||
- validation-report.json
|
|
||||||
- src-tauri/target/release/bundle/nsis/*.exe
|
|
||||||
- src-tauri/target/release/bundle/msi/*.msi
|
|
||||||
expire_in: 30 days
|
|
||||||
Reference in New Issue
Block a user