| 1 | # Pipeline waarmee Steve BlueGit zelf test, bouwt en op master publiceert. |
| 2 | # Eén repository voor bluegit, bluegit-runner en bluegit-backup: |
| 3 | # test vet, unit-tests, frontend en de backup-integratietests (echte |
| 4 | # BlueGit uit deze checkout) |
| 5 | # build build (voor de AUR-jobs, ongewijzigd) en binaries (amd64 + arm64, |
| 6 | # met versie = tag of korte sha) |
| 7 | # package .deb, .rpm en .pkg.tar.zst per programma (nfpm) + SHA256SUMS |
| 8 | # verify installeren in ubuntu:24.04, debian:12, rockylinux:9, fedora en |
| 9 | # archlinux: --version, units, gebruiker, verwijderen |
| 10 | # release master: AUR (bluegit, bluegit-runner, bluegit-backup) en |
| 11 | # self_update; tag v*: release met alle pakketten, alleen als |
| 12 | # alle jobs hierboven slagen (create-only, de tag blijft staan) |
| 13 | # De mirror https://git.timfalken.com/timfa/bluegit leest dit bestand. |
| 14 | # .gitlab-ci.yml blijft de GitLab-pipeline zolang de repository daar nog staat. |
| 15 | # |
| 16 | # Go-jobs gebruiken de preset bluegit/go. Frontend-checks gebruiken bluegit/node. |
| 17 | # De AUR-job blijft op archlinux/archlinux:base-devel: makepkg en pacman |
| 18 | # zitten niet in een preset. |
| 19 | # |
| 20 | # Geheimen op de repository of de groep (een repositorygeheim wint): |
| 21 | # AUR_SSH_PRIVATE_KEY of AUR_SSH_PRIVATE_KEY_B64 |
| 22 | # AUR_GIT_AUTHOR_NAME, AUR_GIT_AUTHOR_EMAIL |
| 23 | # BLUEGIT_UPDATE_TOKEN |
| 24 | # Markeer ze als beschermd en bescherm master. Dan komen ze alleen mee |
| 25 | # op een beschermde branch. Een merge request draait alleen test en build. |
| 26 | |
| 27 | stages: [test, build, package, verify, release] |
| 28 | |
| 29 | variables: |
| 30 | CGO_ENABLED: "0" |
| 31 | # go.mod vraagt Go 1.26 (post-quantum SSH-kex). Een ouder bluegit/go-image |
| 32 | # haalt de juiste toolchain dan zelf op. |
| 33 | GOTOOLCHAIN: auto |
| 34 | |
| 35 | jobs: |
| 36 | .on_ci: |
| 37 | rules: |
| 38 | - if: $CI_PIPELINE_SOURCE == "merge_request_event" |
| 39 | - if: $CI_COMMIT_BRANCH != null |
| 40 | - if: $CI_COMMIT_TAG != null |
| 41 | |
| 42 | .on_tag: |
| 43 | rules: |
| 44 | - if: $CI_COMMIT_TAG =~ /^v[0-9]/ |
| 45 | |
| 46 | .on_master: |
| 47 | rules: |
| 48 | - if: $CI_PIPELINE_SOURCE == "merge_request_event" |
| 49 | when: never |
| 50 | - if: $CI_COMMIT_BRANCH == "master" |
| 51 | - if: $CI_COMMIT_BRANCH == "main" |
| 52 | |
| 53 | vet: |
| 54 | stage: test |
| 55 | image: bluegit/go |
| 56 | extends: .on_ci |
| 57 | script: |
| 58 | - go vet ./... |
| 59 | |
| 60 | test: |
| 61 | stage: test |
| 62 | image: bluegit/go |
| 63 | extends: .on_ci |
| 64 | script: |
| 65 | - go test ./... |
| 66 | |
| 67 | frontend_checks: |
| 68 | stage: test |
| 69 | image: bluegit/node |
| 70 | extends: .on_ci |
| 71 | script: |
| 72 | - chmod +x scripts/frontend-checks.sh |
| 73 | - ./scripts/frontend-checks.sh |
| 74 | |
| 75 | build: |
| 76 | stage: build |
| 77 | image: bluegit/go |
| 78 | extends: .on_ci |
| 79 | script: |
| 80 | - go build -trimpath -ldflags="-s -w" -o bluegit ./cmd/bluegit |
| 81 | artifacts: |
| 82 | paths: [bluegit] |
| 83 | expire_in: 14d |
| 84 | |
| 85 | # De backup server tegen een echte BlueGit, gebouwd uit deze checkout |
| 86 | # (TestMain in internal/backupserver/integration). Elke feature heeft een |
| 87 | # test; release en AUR van bluegit-backup hangen hiervan af. |
| 88 | backup_integration: |
| 89 | stage: test |
| 90 | image: bluegit/go |
| 91 | extends: .on_ci |
| 92 | timeout: 30m |
| 93 | script: |
| 94 | - go vet -tags integration ./internal/backupserver/integration/ |
| 95 | - go test -tags integration -count=1 -v ./internal/backupserver/integration/ |
| 96 | |
| 97 | # Losse binaries voor de release en de pakketten. Versie = tag of korte sha. |
| 98 | binaries: |
| 99 | stage: build |
| 100 | image: bluegit/go |
| 101 | extends: .on_ci |
| 102 | needs: [vet, test, frontend_checks, backup_integration] |
| 103 | script: |
| 104 | - mkdir -p dist |
| 105 | - V="${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}" |
| 106 | - | |
| 107 | for a in amd64 arm64; do |
| 108 | GOARCH=$a go build -trimpath -ldflags="-s -w -X main.version=$V" -o dist/bluegit-linux-$a ./cmd/bluegit |
| 109 | GOARCH=$a go build -trimpath -ldflags="-s -w -X main.version=$V" -o dist/bluegit-runner-linux-$a ./cmd/bluegit-runner |
| 110 | GOARCH=$a go build -trimpath -ldflags="-s -w -X gitlab.com/Timfa/bluegit/internal/backupserver/server.Version=$V" -o dist/bluegit-backup-linux-$a ./cmd/bluegit-backup |
| 111 | done |
| 112 | - dist/bluegit-linux-amd64 --version |
| 113 | artifacts: |
| 114 | paths: [dist/bluegit-linux-amd64, dist/bluegit-linux-arm64, dist/bluegit-runner-linux-amd64, dist/bluegit-runner-linux-arm64, dist/bluegit-backup-linux-amd64, dist/bluegit-backup-linux-arm64] |
| 115 | expire_in: 3d |
| 116 | |
| 117 | # nfpm bouwt per programma .deb, .rpm en .pkg.tar.zst voor amd64 en arm64. |
| 118 | # De artifacts bevatten ook de binaries, zodat de release alles uit één |
| 119 | # job haalt; SHA256SUMS dekt alle 24 bestanden. |
| 120 | package: |
| 121 | stage: package |
| 122 | image: bluegit/go |
| 123 | extends: .on_ci |
| 124 | needs: [binaries] |
| 125 | script: |
| 126 | - go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.43.0 |
| 127 | - export PATH="$(go env GOPATH)/bin:$PATH" |
| 128 | - chmod +x scripts/build-packages.sh |
| 129 | - ./scripts/build-packages.sh |
| 130 | artifacts: |
| 131 | paths: |
| 132 | - dist/SHA256SUMS |
| 133 | - dist/bluegit-linux-amd64 |
| 134 | - dist/bluegit-linux-arm64 |
| 135 | - dist/bluegit_amd64.deb |
| 136 | - dist/bluegit_arm64.deb |
| 137 | - dist/bluegit.x86_64.rpm |
| 138 | - dist/bluegit.aarch64.rpm |
| 139 | - dist/bluegit-x86_64.pkg.tar.zst |
| 140 | - dist/bluegit-aarch64.pkg.tar.zst |
| 141 | - dist/bluegit-runner-linux-amd64 |
| 142 | - dist/bluegit-runner-linux-arm64 |
| 143 | - dist/bluegit-runner_amd64.deb |
| 144 | - dist/bluegit-runner_arm64.deb |
| 145 | - dist/bluegit-runner.x86_64.rpm |
| 146 | - dist/bluegit-runner.aarch64.rpm |
| 147 | - dist/bluegit-runner-x86_64.pkg.tar.zst |
| 148 | - dist/bluegit-runner-aarch64.pkg.tar.zst |
| 149 | - dist/bluegit-backup-linux-amd64 |
| 150 | - dist/bluegit-backup-linux-arm64 |
| 151 | - dist/bluegit-backup_amd64.deb |
| 152 | - dist/bluegit-backup_arm64.deb |
| 153 | - dist/bluegit-backup.x86_64.rpm |
| 154 | - dist/bluegit-backup.aarch64.rpm |
| 155 | - dist/bluegit-backup-x86_64.pkg.tar.zst |
| 156 | - dist/bluegit-backup-aarch64.pkg.tar.zst |
| 157 | expire_in: 3d |
| 158 | |
| 159 | # Installatietest per distro (amd64). Zie scripts/test-package.sh. |
| 160 | .package_test: |
| 161 | stage: verify |
| 162 | needs: [package] |
| 163 | rules: |
| 164 | - if: $CI_PIPELINE_SOURCE == "merge_request_event" |
| 165 | - if: $CI_COMMIT_BRANCH != null |
| 166 | - if: $CI_COMMIT_TAG != null |
| 167 | script: |
| 168 | - bash scripts/test-package.sh |
| 169 | |
| 170 | package_ubuntu: |
| 171 | extends: .package_test |
| 172 | image: ubuntu:24.04 |
| 173 | |
| 174 | package_debian: |
| 175 | extends: .package_test |
| 176 | image: debian:12 |
| 177 | |
| 178 | package_rocky: |
| 179 | extends: .package_test |
| 180 | image: rockylinux:9 |
| 181 | |
| 182 | package_fedora: |
| 183 | extends: .package_test |
| 184 | image: fedora:latest |
| 185 | |
| 186 | package_arch: |
| 187 | extends: .package_test |
| 188 | image: archlinux:latest |
| 189 | |
| 190 | # Vóór self_update. De archive-route staat live, dus de tarball van |
| 191 | # deze sha is te downloaden met de binary die al draait. |
| 192 | # allow_failure: een AUR-storing maakt de pipeline niet rood en houdt |
| 193 | # self_update niet tegen. |
| 194 | publish_aur: |
| 195 | stage: release |
| 196 | image: archlinux/archlinux:base-devel |
| 197 | extends: .on_master |
| 198 | needs: [build] |
| 199 | allow_failure: true |
| 200 | script: |
| 201 | - pacman -Syu --noconfirm |
| 202 | - pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux |
| 203 | - chmod +x scripts/aur-ssh-setup.sh scripts/publish-aur.sh |
| 204 | - ./scripts/aur-ssh-setup.sh |
| 205 | - ./scripts/publish-aur.sh |
| 206 | |
| 207 | # Het aparte runner-pakket. Zelfde AUR-SSH-geheim als publish_aur. |
| 208 | publish_aur_runner: |
| 209 | stage: release |
| 210 | image: archlinux/archlinux:base-devel |
| 211 | extends: .on_master |
| 212 | needs: [build] |
| 213 | allow_failure: true |
| 214 | script: |
| 215 | - pacman -Syu --noconfirm |
| 216 | - pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux |
| 217 | - chmod +x scripts/aur-ssh-setup.sh scripts/publish-aur.sh |
| 218 | - ./scripts/aur-ssh-setup.sh |
| 219 | - AUR_PKG=bluegit-runner ./scripts/publish-aur.sh |
| 220 | |
| 221 | # Het AUR-pakket bluegit-backup (tot 16-11-2026 uit timfa/bluegit-backup). |
| 222 | # Zelfde AUR-SSH-geheim; hangt ook af van de backup-integratietests. |
| 223 | publish_aur_backup: |
| 224 | stage: release |
| 225 | image: archlinux/archlinux:base-devel |
| 226 | extends: .on_master |
| 227 | needs: [build, backup_integration] |
| 228 | allow_failure: true |
| 229 | script: |
| 230 | - pacman -Syu --noconfirm |
| 231 | - pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux |
| 232 | - chmod +x scripts/aur-ssh-setup.sh scripts/publish-aur.sh |
| 233 | - ./scripts/aur-ssh-setup.sh |
| 234 | - AUR_PKG=bluegit-backup ./scripts/publish-aur.sh |
| 235 | |
| 236 | # Release bij een bestaande tag v* (die Tim zet). Create-only: de server |
| 237 | # maakt of verplaatst de tag niet en weigert een tweede release. |
| 238 | release_packages: |
| 239 | stage: release |
| 240 | image: bluegit/base |
| 241 | extends: .on_tag |
| 242 | needs: [vet, test, frontend_checks, backup_integration, build, package, package_ubuntu, package_debian, package_rocky, package_fedora, package_arch] |
| 243 | script: |
| 244 | - chmod +x scripts/build-packages.sh |
| 245 | - ./scripts/build-packages.sh --json "$CI_COMMIT_TAG" "$CI_COMMIT_SHA" BlueGit > release.json |
| 246 | - | |
| 247 | curl -fsS -X POST "$CI_API_URL/repos/$CI_PROJECT_PATH/releases/$CI_COMMIT_TAG/assets" \ |
| 248 | -H "Authorization: Bearer $CI_JOB_TOKEN" \ |
| 249 | -H "Content-Type: application/json" \ |
| 250 | --data-binary @release.json |
| 251 | |
| 252 | # Laatste job. needs: [publish_aur] geldt ook als die job met |
| 253 | # allow_failure mislukt. Alleen de POST; de job eindigt meteen groen. |
| 254 | # De updater bouwt zelf uit git; dit artifact gaat niet mee. |
| 255 | # BLUEGIT_UPDATE_TOKEN is hetzelfde geheim als in /etc/bluegit/env. |
| 256 | # CI_API_URL eindigt op /api/v1. |
| 257 | self_update: |
| 258 | stage: release |
| 259 | image: bluegit/base |
| 260 | extends: .on_master |
| 261 | needs: [publish_aur, publish_aur_runner] |
| 262 | script: |
| 263 | - chmod +x scripts/self-update.sh |
| 264 | - ./scripts/self-update.sh |