gomuks/.gitlab-ci.yml
2025-02-16 20:53:09 +02:00

256 lines
6.2 KiB
YAML

stages:
- frontend
- build
- build desktop
- docker
default:
before_script:
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
cache:
paths:
- .cache
variables:
GOTOOLCHAIN: local
frontend:
image: node:22-alpine
stage: frontend
cache:
paths:
- web/node_modules
script:
- cd web
- npm install --include=dev
- npm run build
artifacts:
paths:
- web/dist
expire_in: 1 hour
.build-linux: &build-linux
stage: build
cache:
paths:
- .cache
before_script:
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
- export GOCACHE="$CI_PROJECT_DIR/.cache/build"
- export MAUTRIX_VERSION=$(cat go.mod | grep 'maunium.net/go/mautrix ' | awk '{ print $2 }')
- export GO_LDFLAGS="-s -w -linkmode external -extldflags -static -X go.mau.fi/gomuks/version.Tag=$CI_COMMIT_TAG -X go.mau.fi/gomuks/version.Commit=$CI_COMMIT_SHA -X 'go.mau.fi/gomuks/version.BuildTime=`date -Iseconds`' -X 'maunium.net/go/mautrix.GoModVersion=$MAUTRIX_VERSION'"
script:
- go build -ldflags "$GO_LDFLAGS" ./cmd/gomuks
artifacts:
paths:
- gomuks
dependencies:
- frontend
needs:
- frontend
.build-docker: &build-docker
image: docker:stable
stage: docker
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- docker build --pull --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH . --file Dockerfile.ci
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH
after_script:
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-$DOCKER_ARCH
linux/amd64:
<<: *build-linux
image: dock.mau.dev/tulir/gomuks-build-docker:linux-amd64
tags:
- linux
- amd64
linux/arm:
<<: *build-linux
image: dock.mau.dev/tulir/gomuks-build-docker:linux-arm
tags:
- linux
- amd64
linux/arm64:
<<: *build-linux
image: dock.mau.dev/tulir/gomuks-build-docker:linux-arm64-native
tags:
- linux
- arm64
windows/amd64:
<<: *build-linux
image: dock.mau.dev/tulir/gomuks-build-docker:windows-amd64
artifacts:
paths:
- gomuks.exe
tags:
- linux
- amd64
macos/arm64:
stage: build
tags:
- macos
- arm64
before_script:
- export PATH=/opt/homebrew/bin:$PATH
- export MAUTRIX_VERSION=$(cat go.mod | grep 'maunium.net/go/mautrix ' | awk '{ print $2 }')
- export GO_LDFLAGS="-X go.mau.fi/gomuks/version.Tag=$CI_COMMIT_TAG -X go.mau.fi/gomuks/version.Commit=$CI_COMMIT_SHA -X 'go.mau.fi/gomuks/version.BuildTime=`date -Iseconds`' -X 'maunium.net/go/mautrix.GoModVersion=$MAUTRIX_VERSION'"
- export LIBRARY_PATH=$(brew --prefix)/lib
- export CPATH=$(brew --prefix)/include
script:
- go build -ldflags "$GO_LDFLAGS" -o gomuks ./cmd/gomuks
- install_name_tool -change $(brew --prefix)/opt/libolm/lib/libolm.3.dylib @rpath/libolm.3.dylib gomuks
- install_name_tool -add_rpath @executable_path gomuks
- install_name_tool -add_rpath /opt/homebrew/opt/libolm/lib gomuks
- install_name_tool -add_rpath /usr/local/opt/libolm/lib gomuks
- cp $(brew --prefix)/opt/libolm/lib/libolm.3.dylib .
artifacts:
paths:
- gomuks
- libolm.3.dylib
dependencies:
- frontend
needs:
- frontend
docker/amd64:
<<: *build-docker
tags:
- linux
- amd64
dependencies:
- linux/amd64
needs:
- linux/amd64
variables:
DOCKER_ARCH: amd64
docker/arm64:
<<: *build-docker
tags:
- linux
- arm64
dependencies:
- linux/arm64
needs:
- linux/arm64
variables:
DOCKER_ARCH: arm64
docker/manifest:
stage: docker
variables:
GIT_STRATEGY: none
before_script:
- "mkdir -p $HOME/.docker && echo '{\"experimental\": \"enabled\"}' > $HOME/.docker/config.json"
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
needs:
- docker/amd64
- docker/arm64
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
- |
if [[ "$CI_COMMIT_BRANCH" == "main" ]]; then
export MANIFEST_NAME="$CI_REGISTRY_IMAGE:latest"
else
export MANIFEST_NAME="$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_NAME//\//_}"
fi
docker manifest create $MANIFEST_NAME $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
docker manifest push $MANIFEST_NAME
- docker rmi $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-amd64 $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA-arm64
.build-desktop: &build-desktop
stage: build desktop
cache:
paths:
- .cache
before_script:
- mkdir -p .cache
- export GOPATH="$CI_PROJECT_DIR/.cache"
- export GOCACHE="$CI_PROJECT_DIR/.cache/build"
script:
- cd desktop
- wails3 task $PLATFORM:package
- ls bin
artifacts:
paths:
- desktop/bin/*
dependencies:
- frontend
needs:
- frontend
desktop/linux/amd64:
<<: *build-desktop
image: dock.mau.dev/tulir/gomuks-build-docker/wails:linux-amd64
variables:
PLATFORM: linux
after_script:
- mv desktop/bin/gomuks-desktop .
- mv desktop/build/nfpm/bin/gomuks-desktop.deb .
artifacts:
paths:
- gomuks-desktop
- gomuks-desktop.deb
tags:
- linux
- amd64
desktop/linux/arm64:
<<: *build-desktop
image: dock.mau.dev/tulir/gomuks-build-docker/wails:linux-arm64-native
variables:
PLATFORM: linux
after_script:
- mv desktop/bin/gomuks-desktop .
- mv desktop/build/nfpm/bin/gomuks-desktop.deb .
artifacts:
paths:
- gomuks-desktop
- gomuks-desktop.deb
tags:
- linux
- arm64
desktop/windows/amd64:
<<: *build-desktop
image: dock.mau.dev/tulir/gomuks-build-docker/wails:windows-amd64
after_script:
- mv desktop/bin/gomuks-desktop.exe .
artifacts:
paths:
- gomuks-desktop.exe
variables:
PLATFORM: windows
desktop/macos/arm64:
<<: *build-desktop
cache: {}
before_script:
- export PATH=/opt/homebrew/bin:/usr/local/bin:$PATH
- export LIBRARY_PATH=$(brew --prefix)/lib
- export CPATH=$(brew --prefix)/include
after_script:
- hdiutil create -srcFolder ./desktop/bin/gomuks-desktop.app/ -o ./gomuks-desktop.dmg
- codesign -s - --timestamp -i fi.mau.gomuks.desktop.mac gomuks-desktop.dmg
- mv desktop/bin/gomuks-desktop .
artifacts:
paths:
- gomuks-desktop
# TODO generate proper dmgs
#- gomuks-desktop.dmg
variables:
PLATFORM: darwin
tags:
- macos
- arm64