signald-go/.gitlab-ci.yml

190 lines
5.9 KiB
YAML
Raw Normal View History

stages:
- build
- test
- publish
lint:
image: golang:1.17
stage: test
2018-10-09 00:39:16 +00:00
before_script:
2021-05-06 03:05:12 +00:00
- apt-get update
- apt-get install -y wget golang-go
2022-02-18 19:07:14 +00:00
- wget https://github.com/golangci/golangci-lint/releases/download/v1.44.2/golangci-lint-1.44.2-linux-amd64.deb
- apt-get install -y ./golangci-lint-1.44.2-linux-amd64.deb
script:
2022-02-18 19:07:14 +00:00
- golangci-lint --timeout 59m run
- go mod tidy
- diff --color=always go.mod "${CI_PROJECT_DIR}/go.mod"
- diff --color=always go.sum "${CI_PROJECT_DIR}/go.sum"
rules:
- when: on_success
needs: []
test sqlite to postgres:
2022-05-17 23:58:02 +00:00
image:
name: registry.gitlab.com/signald/signald:unstable
2022-05-18 00:03:05 +00:00
entrypoint: [""]
stage: test
needs:
- "build:x86"
before_script:
2022-05-18 00:25:11 +00:00
- apt-get update && apt-get install -y postgresql-client
script:
- cd /
- signald --migrate-data
- echo 'CREATE DATABASE signald' | psql -h postgres -U postgres -a
2022-05-18 00:43:39 +00:00
- "${CI_PROJECT_DIR}/signaldctl db-move postgresql://postgres@postgres/signald?sslmode=disable"
2022-05-18 00:55:38 +00:00
- SIGNALD_DATABASE=postgresql://postgres@postgres/signald?sslmode=disable signald --migrate-data
2022-05-18 00:51:56 +00:00
variables:
SIGNALD_VERBOSE_LOGGING: "true"
services:
2022-05-18 00:34:53 +00:00
- name: postgres:latest
alias: postgres
variables:
POSTGRES_HOST_AUTH_METHOD: trust
2021-02-03 08:10:45 +00:00
.build:
stage: build
image: golang:latest
2018-10-09 00:39:16 +00:00
before_script:
- mkdir -p /go/src/gitlab.com/signald/signald-go
- cp -r * /go/src/gitlab.com/signald/signald-go
script:
2021-08-07 19:46:18 +00:00
- VERSION="$(./version.sh)"
2021-02-03 08:10:45 +00:00
- echo "building ${VERSION}"
- cd /go/src/gitlab.com/signald/signald-go
- go build -o "${CI_PROJECT_DIR}/signaldctl" --ldflags "-X gitlab.com/signald/signald-go/cmd/signaldctl/common.Version=${VERSION} -X gitlab.com/signald/signald-go/cmd/signaldctl/common.Branch=${CI_COMMIT_BRANCH} -X gitlab.com/signald/signald-go/cmd/signaldctl/common.Commit=${CI_COMMIT_SHA}" ./cmd/signaldctl
artifacts:
paths:
2020-12-13 00:33:29 +00:00
- signaldctl
expire_in: 1 month
2020-12-13 02:43:30 +00:00
2021-07-09 08:44:10 +00:00
.build-deb:
stage: build
2021-08-26 00:00:23 +00:00
image: debian:buster
2021-07-09 08:44:10 +00:00
script:
- echo deb http://deb.debian.org/debian buster-backports main > /etc/apt/sources.list.d/backports.list
2021-07-09 08:44:10 +00:00
- apt-get update
2022-02-18 19:07:14 +00:00
- apt-get install -y -t buster-backports git-buildpackage dh-golang bash-completion golang-any golang-github-spf13-cobra-dev golang-github-spf13-viper-dev golang-github-google-uuid-dev golang-github-mattn-go-sqlite3-dev golang-github-lib-pq-dev golang-github-satori-go.uuid-dev
2021-07-09 08:44:10 +00:00
- apt-get install -y ./*.deb && rm -vf *.deb
- 'sed -i "s/^Architecture:.*/Architecture: ${ARCH}/g" debian/control'
2021-07-09 08:44:10 +00:00
- go run ./cmd/signaldctl doc -o man
- go run ./cmd/signaldctl completion bash > debian/package.bash-completion
- ls *.1 > debian/manpages
2021-08-07 19:46:18 +00:00
- gbp dch --ignore-branch --debian-tag="%(version)s" --git-author --new-version="$(./version.sh)"
2021-07-09 08:44:10 +00:00
- dpkg-buildpackage -us -uc -b
- mv ../*.deb .
needs:
- project: signald/libraries/golang-github-mdp-qrterminal
job: build
ref: master
artifacts: true
- project: signald/libraries/golang-github-jedib0t-go-pretty
job: build
ref: master
artifacts: true
variables:
SIGNALDCTL_PUBLIC_DOC_MODE: "on"
artifacts:
paths:
- "*.deb"
- "*.1"
expire_in: 1 month
rules:
- if: '$CI_PROJECT_NAMESPACE == "signald" && $CI_COMMIT_REF_PROTECTED == "true"'
when: on_success
- when: manual
allow_failure: true
2021-07-09 08:44:10 +00:00
2021-02-03 08:10:45 +00:00
build:x86:
extends: .build
rules:
- when: on_success
2021-02-03 08:10:45 +00:00
build:aarch64:
tags: [arm-builder]
extends: .build
2021-04-05 22:25:42 +00:00
rules:
- if: '$CI_PROJECT_NAMESPACE == "signald" && $CI_COMMIT_REF_PROTECTED == "true"'
when: on_success
- when: manual
allow_failure: true
2021-02-03 08:10:45 +00:00
2021-02-03 05:33:47 +00:00
build:cross-compile:
stage: build
image: golang:latest
before_script:
- mkdir -p /go/src/gitlab.com/signald/signald-go
- cp -r * /go/src/gitlab.com/signald/signald-go
script:
2021-08-07 19:46:18 +00:00
- VERSION="$(./version.sh)"
2021-02-03 08:10:45 +00:00
- echo "building ${VERSION}"
- cd /go/src/gitlab.com/signald/signald-go
- go build -o "${CI_PROJECT_DIR}/signaldctl-${GOOS}-${GOARCH}" --ldflags "-X gitlab.com/signald/signald-go/cmd/signaldctl/common.Version=${VERSION} -X gitlab.com/signald/signald-go/cmd/signaldctl/common.Branch=${CI_COMMIT_BRANCH} -X gitlab.com/signald/signald-go/cmd/signaldctl/common.Commit=${CI_COMMIT_SHA}" ./cmd/signaldctl
2021-02-03 05:33:47 +00:00
artifacts:
paths:
- signaldctl-*
expire_in: 1 month
parallel:
matrix:
- GOOS: linux
GOARCH:
- arm
- arm64
- amd64
- GOOS: darwin
GOARCH: amd64
rules:
- when: on_success
2021-02-03 05:33:47 +00:00
build:x86:deb:
2021-07-09 08:44:10 +00:00
extends: .build-deb
rules:
- when: on_success
variables:
ARCH: amd64
2021-04-05 22:25:42 +00:00
build:aarch64:deb:
2021-07-09 08:44:10 +00:00
extends: .build-deb
2021-04-05 22:25:42 +00:00
tags: [arm-builder]
variables:
ARCH: arm64
2021-04-05 22:25:42 +00:00
2021-07-09 20:26:35 +00:00
build:armhf:deb:
extends: .build-deb
2021-08-26 00:00:23 +00:00
image: arm32v7/debian:buster
2021-07-09 20:26:35 +00:00
tags: [arm-builder]
variables:
ARCH: armhf
2021-07-09 20:26:35 +00:00
2021-02-02 23:03:17 +00:00
publish deb:
image: registry.gitlab.com/signald/infrastructure/signald-builder-x86:d5e68709
stage: publish
tags: [deb-signer]
2021-07-09 20:26:35 +00:00
needs: ["build:x86:deb", "build:aarch64:deb", "build:armhf:deb"]
script:
- aptly repo create signald
- aptly mirror create -ignore-signatures backfill-mirror https://updates.signald.org "${DISTRIBUTION}" main
- aptly mirror update -ignore-signatures backfill-mirror
2022-02-23 15:16:27 +00:00
- aptly repo import backfill-mirror signald signald 'signaldctl (>= 0.3.0)'
- aptly repo add signald *.deb
2022-02-23 15:16:27 +00:00
- gpg1 --import "${SIGNING_KEY_PATH}"
- gpg1 --list-secret-keys
- aptly publish repo -config=.aptly.conf -batch -gpg-key="${SIGNING_KEY_ID}" -distribution="${DISTRIBUTION}" "signald" "s3:updates.signald.org:"
variables:
DISTRIBUTION: unstable
rules:
- if: '$CI_PROJECT_NAMESPACE == "signald" && $CI_COMMIT_REF_PROTECTED == "true"'
when: on_success
- when: manual
allow_failure: true
2021-02-02 21:40:02 +00:00
2021-07-24 01:38:05 +00:00
signald.org:
2021-02-02 21:40:02 +00:00
stage: publish
needs: ["build:x86"]
2021-03-26 01:02:09 +00:00
trigger: signald/signald.org
rules:
- if: '$CI_PROJECT_NAMESPACE == "signald" && $CI_COMMIT_REF_PROTECTED == "true"'
when: on_success