Migrate GitHub automation to GitLab CI
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
approve-container-release:
|
||||
stage: package
|
||||
image: alpine:3.22
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "web" && $RELEASE_VERSION =~ /^\d+\.\d+\.\d+$/'
|
||||
when: manual
|
||||
environment:
|
||||
name: overlord-container-release
|
||||
script:
|
||||
- echo "Approved container release ${RELEASE_VERSION}"
|
||||
|
||||
container-build:
|
||||
stage: package
|
||||
image: docker:27.5.1-cli
|
||||
services:
|
||||
- name: docker:27.5.1-dind
|
||||
command: ["--mtu=1400"]
|
||||
needs:
|
||||
- approve-container-release
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "web" && $RELEASE_VERSION =~ /^\d+\.\d+\.\d+$/'
|
||||
parallel:
|
||||
matrix:
|
||||
- PLATFORM: linux/amd64
|
||||
ARCH: amd64
|
||||
RUNNER_TAG: saas-linux-small-amd64
|
||||
- PLATFORM: linux/arm64
|
||||
ARCH: arm64
|
||||
RUNNER_TAG: saas-linux-small-arm64
|
||||
tags:
|
||||
- $RUNNER_TAG
|
||||
variables:
|
||||
DOCKER_TLS_CERTDIR: /certs
|
||||
before_script:
|
||||
- echo "$CI_REGISTRY_PASSWORD" | docker login --username "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
|
||||
- docker buildx create --driver docker-container --use
|
||||
- docker buildx inspect --bootstrap
|
||||
script:
|
||||
- |
|
||||
set -eu
|
||||
client_version=$(sed -nE 's/.*AgentVersion[[:space:]]*=[[:space:]]*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' Overlord-Client/cmd/agent/config/config.go | head -n1)
|
||||
server_version=$(sed -nE 's/.*SERVER_VERSION[[:space:]]*=[[:space:]]*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' Overlord-Server/src/version.ts | head -n1)
|
||||
package_version=$(sed -nE 's/[[:space:]]*"version":[[:space:]]*"([0-9]+\.[0-9]+\.[0-9]+)".*/\1/p' Overlord-Server/package.json | head -n1)
|
||||
test -n "$client_version"
|
||||
test "$client_version" = "$server_version"
|
||||
test "$client_version" = "$package_version"
|
||||
test "$RELEASE_VERSION" = "$client_version"
|
||||
- |
|
||||
set -eu
|
||||
metadata_file=$(mktemp)
|
||||
docker buildx build \
|
||||
--file Dockerfile \
|
||||
--platform "$PLATFORM" \
|
||||
--label "org.opencontainers.image.source=$CI_PROJECT_URL" \
|
||||
--label "org.opencontainers.image.revision=$CI_COMMIT_SHA" \
|
||||
--cache-from "type=registry,ref=$CI_REGISTRY_IMAGE:buildcache-$ARCH" \
|
||||
--cache-to "type=registry,ref=$CI_REGISTRY_IMAGE:buildcache-$ARCH,mode=max" \
|
||||
--output "type=image,name=$CI_REGISTRY_IMAGE,push-by-digest=true,name-canonical=true,push=true" \
|
||||
--metadata-file "$metadata_file" \
|
||||
.
|
||||
digest=$(sed -nE 's/.*"containerimage.digest"[[:space:]]*:[[:space:]]*"sha256:([a-f0-9]+)".*/\1/p' "$metadata_file" | head -n1)
|
||||
test -n "$digest"
|
||||
mkdir -p digests
|
||||
touch "digests/$digest"
|
||||
artifacts:
|
||||
expire_in: 1 day
|
||||
paths:
|
||||
- digests/
|
||||
|
||||
container-publish:
|
||||
stage: release
|
||||
image: docker:27.5.1-cli
|
||||
services:
|
||||
- name: docker:27.5.1-dind
|
||||
command: ["--mtu=1400"]
|
||||
tags:
|
||||
- saas-linux-small-amd64
|
||||
needs:
|
||||
- job: container-build
|
||||
artifacts: true
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "web" && $RELEASE_VERSION =~ /^\d+\.\d+\.\d+$/'
|
||||
variables:
|
||||
DOCKER_TLS_CERTDIR: /certs
|
||||
before_script:
|
||||
- echo "$CI_REGISTRY_PASSWORD" | docker login --username "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
|
||||
- docker buildx create --driver docker-container --use
|
||||
- docker buildx inspect --bootstrap
|
||||
script:
|
||||
- |
|
||||
set -eu
|
||||
major=${RELEASE_VERSION%%.*}
|
||||
remainder=${RELEASE_VERSION#*.}
|
||||
minor=${remainder%%.*}
|
||||
set --
|
||||
for digest_file in digests/*; do
|
||||
set -- "$@" "$CI_REGISTRY_IMAGE@sha256:$(basename "$digest_file")"
|
||||
done
|
||||
test "$#" -eq 2
|
||||
docker buildx imagetools create \
|
||||
--tag "$CI_REGISTRY_IMAGE:$RELEASE_VERSION" \
|
||||
--tag "$CI_REGISTRY_IMAGE:$major.$minor" \
|
||||
--tag "$CI_REGISTRY_IMAGE:$major" \
|
||||
--tag "$CI_REGISTRY_IMAGE:latest" \
|
||||
"$@"
|
||||
docker buildx imagetools inspect "$CI_REGISTRY_IMAGE:$RELEASE_VERSION"
|
||||
@@ -0,0 +1,88 @@
|
||||
desktop-build-windows:
|
||||
stage: package
|
||||
tags:
|
||||
- saas-windows-medium-amd64
|
||||
rules:
|
||||
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
||||
changes:
|
||||
- Overlord-Desktop/package.json
|
||||
- Overlord-Desktop/bun.lock
|
||||
- Overlord-Desktop/scripts/**/*
|
||||
- Overlord-Desktop/src/**/*
|
||||
- Overlord-Desktop/src-tauri/**/*
|
||||
before_script:
|
||||
- npm install --global --prefix "$env:CI_PROJECT_DIR\.tools" bun@1.3.14
|
||||
- $env:PATH = "$env:CI_PROJECT_DIR\.tools;$env:USERPROFILE\.cargo\bin;$env:PATH"
|
||||
- |
|
||||
if (-not (Get-Command rustup -ErrorAction SilentlyContinue)) {
|
||||
Invoke-WebRequest -UseBasicParsing https://win.rustup.rs/x86_64 -OutFile "$env:CI_PROJECT_DIR\rustup-init.exe"
|
||||
& "$env:CI_PROJECT_DIR\rustup-init.exe" -y --profile minimal
|
||||
}
|
||||
- rustup toolchain install stable --profile minimal
|
||||
- rustup default stable
|
||||
script:
|
||||
- Set-Location Overlord-Desktop
|
||||
- |
|
||||
$Version = (Get-Content package.json | ConvertFrom-Json).version
|
||||
if ($Version -notmatch '^\d+\.\d+\.\d+$') {
|
||||
throw "package.json version must be strict X.Y.Z SemVer; got '$Version'"
|
||||
}
|
||||
$Tag = "Overlord-Desktop-v$Version"
|
||||
if (git ls-remote --exit-code --tags origin "refs/tags/$Tag") {
|
||||
throw "Release tag already exists: $Tag"
|
||||
}
|
||||
$env:DESKTOP_VERSION = $Version
|
||||
$env:DESKTOP_TAG = $Tag
|
||||
"DESKTOP_VERSION=$Version" | Out-File -FilePath "$env:CI_PROJECT_DIR\desktop.env" -Encoding ascii
|
||||
"DESKTOP_TAG=$Tag" | Out-File -FilePath "$env:CI_PROJECT_DIR\desktop.env" -Encoding ascii -Append
|
||||
- bun install --frozen-lockfile
|
||||
- bun run vendor
|
||||
- bun run build:win
|
||||
- |
|
||||
$Installer = Get-ChildItem -Path src-tauri\target\release\bundle\nsis\*.exe -ErrorAction Stop | Select-Object -First 1
|
||||
$ReleaseDirectory = New-Item -ItemType Directory -Path "$env:CI_PROJECT_DIR\release" -Force
|
||||
$InstallerName = "Overlord-Desktop-$env:DESKTOP_VERSION-setup.exe"
|
||||
Copy-Item -LiteralPath $Installer.FullName -Destination (Join-Path $ReleaseDirectory $InstallerName)
|
||||
Copy-Item -LiteralPath PLEASE_READ.txt -Destination $ReleaseDirectory
|
||||
"INSTALLER_NAME=$InstallerName" | Out-File -FilePath "$env:CI_PROJECT_DIR\desktop.env" -Encoding ascii -Append
|
||||
artifacts:
|
||||
expire_in: 30 days
|
||||
paths:
|
||||
- release/
|
||||
reports:
|
||||
dotenv: desktop.env
|
||||
|
||||
desktop-release:
|
||||
stage: release
|
||||
image: registry.gitlab.com/gitlab-org/cli:latest
|
||||
needs:
|
||||
- job: desktop-build-windows
|
||||
artifacts: true
|
||||
rules:
|
||||
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
||||
changes:
|
||||
- Overlord-Desktop/package.json
|
||||
- Overlord-Desktop/bun.lock
|
||||
- Overlord-Desktop/scripts/**/*
|
||||
- Overlord-Desktop/src/**/*
|
||||
- Overlord-Desktop/src-tauri/**/*
|
||||
script:
|
||||
- |
|
||||
set -eu
|
||||
package_base="$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/overlord-desktop/$DESKTOP_VERSION"
|
||||
curl --fail --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file "release/$INSTALLER_NAME" "$package_base/$INSTALLER_NAME"
|
||||
curl --fail --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file release/PLEASE_READ.txt "$package_base/PLEASE_READ.txt"
|
||||
release:
|
||||
tag_name: $DESKTOP_TAG
|
||||
tag_message: "Overlord Desktop v$DESKTOP_VERSION"
|
||||
name: "Overlord Desktop v$DESKTOP_VERSION"
|
||||
description: "Automated build release for Overlord Desktop v$DESKTOP_VERSION"
|
||||
ref: $CI_COMMIT_SHA
|
||||
assets:
|
||||
links:
|
||||
- name: $INSTALLER_NAME
|
||||
url: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/overlord-desktop/$DESKTOP_VERSION/$INSTALLER_NAME"
|
||||
link_type: package
|
||||
- name: PLEASE_READ.txt
|
||||
url: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/overlord-desktop/$DESKTOP_VERSION/PLEASE_READ.txt"
|
||||
link_type: other
|
||||
@@ -0,0 +1,114 @@
|
||||
.server-test-rules:
|
||||
rules:
|
||||
- changes:
|
||||
- Overlord-Server/**/*
|
||||
- Overlord-Client/cmd/agent/wire/wire_contract_generated.go
|
||||
- protocol/**/*
|
||||
- scripts/generate-wire-protocol.ts
|
||||
- .gitlab-ci.yml
|
||||
- .gitlab/ci/tests.yml
|
||||
|
||||
.client-test-rules:
|
||||
rules:
|
||||
- changes:
|
||||
- Overlord-Client/**/*
|
||||
- protocol/**/*
|
||||
- scripts/generate-wire-protocol.ts
|
||||
- go.work
|
||||
- go.work.sum
|
||||
- .gitlab-ci.yml
|
||||
- .gitlab/ci/tests.yml
|
||||
|
||||
server-tests-linux:
|
||||
extends: .server-test-rules
|
||||
stage: test
|
||||
image: oven/bun:1.3.14
|
||||
script:
|
||||
- cd Overlord-Server
|
||||
- bun install --frozen-lockfile
|
||||
- bun run typecheck
|
||||
- bun run protocol:check
|
||||
- bun run test
|
||||
|
||||
server-tests-macos:
|
||||
extends: .server-test-rules
|
||||
stage: test
|
||||
tags:
|
||||
- saas-macos-medium-m1
|
||||
image: macos-15-xcode-16
|
||||
before_script:
|
||||
- npm install --global --prefix "$CI_PROJECT_DIR/.tools" bun@1.3.14
|
||||
- export PATH="$CI_PROJECT_DIR/.tools/bin:$PATH"
|
||||
script:
|
||||
- cd Overlord-Server
|
||||
- bun install --frozen-lockfile
|
||||
- bun run typecheck
|
||||
- bun run protocol:check
|
||||
- bun run test
|
||||
|
||||
server-tests-windows:
|
||||
extends: .server-test-rules
|
||||
stage: test
|
||||
tags:
|
||||
- saas-windows-medium-amd64
|
||||
before_script:
|
||||
- npm install --global --prefix "$env:CI_PROJECT_DIR\.tools" bun@1.3.14
|
||||
- $env:PATH = "$env:CI_PROJECT_DIR\.tools;$env:PATH"
|
||||
script:
|
||||
- Set-Location Overlord-Server
|
||||
- bun install --frozen-lockfile
|
||||
- bun run typecheck
|
||||
- bun run protocol:check
|
||||
- bun run test
|
||||
|
||||
server-e2e-tests:
|
||||
extends: .server-test-rules
|
||||
stage: test
|
||||
image: oven/bun:1.3.14
|
||||
script:
|
||||
- cd Overlord-Server
|
||||
- bun install --frozen-lockfile
|
||||
- bunx playwright install --with-deps chromium
|
||||
- bun run test:e2e
|
||||
|
||||
client-tests-linux:
|
||||
extends: .client-test-rules
|
||||
stage: test
|
||||
image: golang:1.26-bookworm
|
||||
script:
|
||||
- cd Overlord-Client
|
||||
- go mod download
|
||||
- go test ./...
|
||||
|
||||
client-tests-macos:
|
||||
extends: .client-test-rules
|
||||
stage: test
|
||||
tags:
|
||||
- saas-macos-medium-m1
|
||||
image: macos-15-xcode-16
|
||||
before_script:
|
||||
- export GO_VERSION="$(awk '/^go / { print $2; exit }' Overlord-Client/go.mod)"
|
||||
- mkdir -p "$CI_PROJECT_DIR/.toolchains"
|
||||
- curl --fail --silent --show-error --location "https://go.dev/dl/go${GO_VERSION}.darwin-arm64.tar.gz" | tar -xz -C "$CI_PROJECT_DIR/.toolchains"
|
||||
- export PATH="$CI_PROJECT_DIR/.toolchains/go/bin:$PATH"
|
||||
script:
|
||||
- cd Overlord-Client
|
||||
- go mod download
|
||||
- go test ./...
|
||||
|
||||
client-tests-windows:
|
||||
extends: .client-test-rules
|
||||
stage: test
|
||||
tags:
|
||||
- saas-windows-medium-amd64
|
||||
before_script:
|
||||
- $GoVersion = ((Select-String -Path Overlord-Client/go.mod -Pattern '^go ').Line -split '\s+')[1]
|
||||
- Invoke-WebRequest -UseBasicParsing "https://go.dev/dl/go$GoVersion.windows-amd64.zip" -OutFile "$env:CI_PROJECT_DIR\go.zip"
|
||||
- Expand-Archive -Path "$env:CI_PROJECT_DIR\go.zip" -DestinationPath "$env:CI_PROJECT_DIR\.toolchains" -Force
|
||||
- $env:PATH = "$env:CI_PROJECT_DIR\.toolchains\go\bin;$env:PATH"
|
||||
script:
|
||||
- bash scripts/vendor-onevpl-headers.sh
|
||||
- bash scripts/vendor-amf-headers.sh
|
||||
- Set-Location Overlord-Client
|
||||
- go mod download
|
||||
- go test ./...
|
||||
Reference in New Issue
Block a user