Skip to content

Commit a8fdbb8

Browse files
committed
TUN-9800: Add pipelines for linux packaging
1 parent 70658b8 commit a8fdbb8

File tree

11 files changed

+227
-280
lines changed

11 files changed

+227
-280
lines changed

.ci/commons.gitlab-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
# Rules to run the job only on the master branch
44
run-on-master:
55
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
6-
when: always
6+
when: on_success
77
- when: never
88
# Rules to run the job only on merge requests
99
run-on-mr:
1010
- if: $CI_COMMIT_TAG
1111
when: never
1212
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
13-
when: always
13+
when: on_success
1414
- when: never
1515
# Rules to run the job on merge_requests and master branch
1616
run-always:
1717
- if: $CI_COMMIT_TAG
1818
when: never
1919
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
2020
- if: $CI_COMMIT_BRANCH != null && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
21-
when: always
21+
when: on_success
2222
- when: never
2323

2424
# This before_script is injected into every job that runs on master meaning that if there is no tag the step

.ci/image/Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ RUN apt-get update && \
1616
python3-venv \
1717
# libmsi and libgcab are libraries the wixl binary depends on.
1818
libmsi-dev \
19-
libgcab-dev && \
19+
libgcab-dev \
20+
# deb and rpm build tools
21+
rubygem-fpm \
22+
rpm \
23+
# create deb and rpm repository files
24+
reprepro \
25+
createrepo-c && \
2026
rm -rf /var/lib/apt/lists/* && \
2127
# Install wixl
2228
curl -o /usr/local/bin/wixl -L https://pkg.cloudflare.com/binaries/wixl && \

.ci/linux.gitlab-ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
imageVersion: "3371-f5539bd6f83d@sha256:a2a68f580070f9411d0d3155959ed63b700ef319b5fcc62db340e92227bbc628"
99
CGO_ENABLED: 1
1010

11+
.default-packaging-job: &packaging-job-defaults
12+
stage: build
13+
needs:
14+
- ci-image-get-image-ref
15+
rules:
16+
- !reference [.default-rules, run-on-master]
17+
image: $BUILD_IMAGE
18+
cache: {}
19+
artifacts:
20+
paths:
21+
- artifacts/*
22+
1123
include:
1224
###################
1325
### Linux Build ###
@@ -89,3 +101,22 @@ component-tests-linux-fips:
89101
variables:
90102
<<: *component-tests-variables
91103
COMPONENT_TESTS_FIPS: 1
104+
105+
################################
106+
####### Linux Packaging ########
107+
################################
108+
linux-packaging:
109+
<<: *packaging-job-defaults
110+
parallel:
111+
matrix:
112+
- ARCH: ["386", "amd64", "arm", "armhf", "arm64"]
113+
script:
114+
- ./.ci/scripts/linux/build-packages.sh ${ARCH}
115+
116+
################################
117+
##### Linux FIPS Packaging #####
118+
################################
119+
linux-packaging-fips:
120+
<<: *packaging-job-defaults
121+
script:
122+
- ./.ci/scripts/linux/build-packages-fips.sh

.ci/release.gitlab-ci.yml

Lines changed: 102 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,123 @@
11
include:
22
- local: .ci/commons.gitlab-ci.yml
33

4-
###########################################
5-
### Push Cloudflared Binaries to Github ###
6-
###########################################
7-
release-cloudflared-to-github:
4+
######################################
5+
### Build and Push DockerHub Image ###
6+
######################################
7+
- component: $CI_SERVER_FQDN/cloudflare/ci/docker-image/build-push-image@~latest
8+
inputs:
9+
stage: release
10+
jobPrefix: docker-hub
11+
runOnMR: false
12+
runOnBranches: '^master$'
13+
runOnChangesTo: ['RELEASE_NOTES']
14+
needs:
15+
- generate-version-file
16+
- release-cloudflared-to-r2
17+
commentImageRefs: false
18+
runner: vm-linux-x86-4cpu-8gb
19+
DOCKER_USER_BRANCH: svcgithubdockerhubcloudflar045
20+
DOCKER_PASSWORD_BRANCH: gitlab/cloudflare/tun/cloudflared/_dev/dockerhub/svc_password/data
21+
EXTRA_DIB_ARGS: --overwrite
22+
23+
.default-release-job: &release-job-defaults
824
stage: release
925
image: $BUILD_IMAGE
10-
extends: .check-tag
11-
needs:
12-
- ci-image-get-image-ref
13-
- package-windows
14-
- build-and-sign-cloudflared-macos
1526
rules:
1627
- !reference [.default-rules, run-on-master]
1728
cache:
1829
paths:
1930
- .cache/pip
2031
variables:
2132
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
33+
# KV Vars
2234
KV_NAMESPACE: 380e19aa04314648949b6ad841417ebe
23-
KV_ACCOUNT: 5ab4e9dfbd435d24068829fda0077963
35+
KV_ACCOUNT: &cf-account 5ab4e9dfbd435d24068829fda0077963
36+
# R2 Vars
37+
R2_BUCKET: cloudflared-pkgs
38+
R2_ACCOUNT_ID: *cf-account
39+
# APT and RPM Repository Vars
40+
GPG_PUBLIC_KEY_URL: "https://pkg.cloudflare.com/cloudflare-ascii-pubkey.gpg"
41+
PKG_URL: "https://pkg.cloudflare.com/cloudflared"
42+
BINARY_NAME: cloudflared
2443
secrets:
2544
KV_API_TOKEN:
2645
vault: gitlab/cloudflare/tun/cloudflared/_dev/cfd_kv_api_token/data@kv
2746
file: false
2847
API_KEY:
2948
vault: gitlab/cloudflare/tun/cloudflared/_dev/cfd_github_api_key/data@kv
3049
file: false
50+
R2_CLIENT_ID:
51+
vault: gitlab/cloudflare/tun/cloudflared/_dev/_terraform_atlantis/r2_api_token/client_id@kv
52+
file: false
53+
R2_CLIENT_SECRET:
54+
vault: gitlab/cloudflare/tun/cloudflared/_dev/_terraform_atlantis/r2_api_token/client_secret@kv
55+
file: false
56+
LINUX_SIGNING_PUBLIC_KEY:
57+
vault: gitlab/cloudflare/tun/cloudflared/_dev/gpg_v1/public_key@kv
58+
file: false
59+
LINUX_SIGNING_PRIVATE_KEY:
60+
vault: gitlab/cloudflare/tun/cloudflared/_dev/gpg_v1/private_key@kv
61+
file: false
62+
LINUX_SIGNING_PUBLIC_KEY_2:
63+
vault: gitlab/cloudflare/tun/cloudflared/_dev/gpg_v2/public_key@kv
64+
file: false
65+
LINUX_SIGNING_PRIVATE_KEY_2:
66+
vault: gitlab/cloudflare/tun/cloudflared/_dev/gpg_v2/private_key@kv
67+
file: false
68+
69+
###########################################
70+
### Push Cloudflared Binaries to Github ###
71+
###########################################
72+
release-cloudflared-to-github:
73+
<<: *release-job-defaults
74+
extends: .check-tag
75+
needs:
76+
- build-and-sign-cloudflared-macos
77+
- ci-image-get-image-ref
78+
- linux-packaging
79+
- linux-packaging-fips
80+
- package-windows
81+
script:
82+
- ./.ci/scripts/release-target.sh github-release
83+
84+
#########################################
85+
### Upload Cloudflared Binaries to R2 ###
86+
#########################################
87+
release-cloudflared-to-r2:
88+
<<: *release-job-defaults
89+
extends: .check-tag
90+
needs:
91+
- ci-image-get-image-ref
92+
- linux-packaging # We only release non-FIPS binaries to R2
93+
- release-cloudflared-to-github
3194
script:
32-
- python3 --version ; pip --version # For debugging
33-
- python3 -m venv venv
34-
- source venv/bin/activate
35-
- pip install pynacl==1.4.0 pygithub==1.55
36-
- echo $VERSION
37-
- echo $TAG_EXISTS
38-
- echo "Running release because tag exists."
39-
- make gitlab-release
95+
- ./.ci/scripts/release-target.sh r2-linux-release
96+
97+
#################################################
98+
### Upload Cloudflared Nightly Binaries to R2 ###
99+
#################################################
100+
release-cloudflared-nightly-to-r2:
101+
<<: *release-job-defaults
102+
variables:
103+
R2_BUCKET: cloudflared-pkgs-next
104+
GPG_PUBLIC_KEY_URL: "https://next.pkg.cloudflare.com/cloudflare-ascii-pubkey.gpg"
105+
PKG_URL: "https://next.pkg.cloudflare.com/cloudflared"
106+
needs:
107+
- ci-image-get-image-ref
108+
- linux-packaging # We only release non-FIPS binaries to R2
109+
script:
110+
- ./.ci/scripts/release-target.sh r2-linux-release
111+
112+
#############################
113+
### Generate Version File ###
114+
#############################
115+
generate-version-file:
116+
<<: *release-job-defaults
117+
needs:
118+
- ci-image-get-image-ref
119+
script:
120+
- make generate-docker-version
121+
artifacts:
122+
paths:
123+
- versions
File renamed without changes.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
# Check if architecture argument is provided
4+
if [ $# -eq 0 ]; then
5+
echo "Error: Architecture argument is required"
6+
echo "Usage: $0 <architecture>"
7+
exit 1
8+
fi
9+
10+
# Parameters
11+
arch=$1
12+
13+
# Get Version
14+
VERSION=$(git describe --tags --always --match "[0-9][0-9][0-9][0-9].*.*")
15+
echo $VERSION
16+
17+
# Disable FIPS module in go-boring
18+
export GOEXPERIMENT=noboringcrypto
19+
export CGO_ENABLED=0
20+
21+
# This controls the directory the built artifacts go into
22+
export ARTIFACT_DIR=artifacts/
23+
mkdir -p $ARTIFACT_DIR
24+
25+
export TARGET_OS=linux
26+
27+
unset TARGET_ARM
28+
export TARGET_ARCH=$arch
29+
30+
## Support for arm platforms without hardware FPU enabled
31+
if [[ $arch == arm ]] ; then
32+
export TARGET_ARCH=arm
33+
export TARGET_ARM=5
34+
fi
35+
36+
## Support for armhf builds
37+
if [[ $arch == armhf ]] ; then
38+
export TARGET_ARCH=arm
39+
export TARGET_ARM=7
40+
fi
41+
42+
make cloudflared-deb
43+
mv cloudflared\_$VERSION\_$arch.deb $ARTIFACT_DIR/cloudflared-linux-$arch.deb
44+
45+
# rpm packages invert the - and _ and use x86_64 instead of amd64.
46+
RPMVERSION=$(echo $VERSION|sed -r 's/-/_/g')
47+
RPMARCH=$arch
48+
if [ $arch == "amd64" ];then
49+
RPMARCH="x86_64"
50+
fi
51+
if [ $arch == "arm64" ]; then
52+
RPMARCH="aarch64"
53+
fi
54+
make cloudflared-rpm
55+
mv cloudflared-$RPMVERSION-1.$RPMARCH.rpm $ARTIFACT_DIR/cloudflared-linux-$RPMARCH.rpm
56+
57+
# finally move the linux binary as well.
58+
mv ./cloudflared $ARTIFACT_DIR/cloudflared-linux-$arch
59+

.ci/scripts/release-target.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
set -e -o pipefail
3+
4+
# Check if a make target is provided as an argument
5+
if [ $# -eq 0 ]; then
6+
echo "Error: Make target argument is required"
7+
echo "Usage: $0 <make-target>"
8+
exit 1
9+
fi
10+
11+
MAKE_TARGET=$1
12+
13+
python3 -m venv venv
14+
source venv/bin/activate
15+
16+
# Our release scripts are written in python, so we should install their dependecies here.
17+
pip install pynacl==1.4.0 pygithub==1.55 boto3==1.22.9 python-gnupg==0.4.9
18+
make $MAKE_TARGET

Makefile

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,6 @@ cloudflared-deb: cloudflared cloudflared.1
221221
cloudflared-rpm: cloudflared cloudflared.1
222222
$(call build_package,rpm)
223223

224-
.PHONY: cloudflared-pkg
225-
cloudflared-pkg: cloudflared cloudflared.1
226-
$(call build_package,osxpkg)
227-
228224
.PHONY: cloudflared-msi
229225
cloudflared-msi:
230226
wixl --define Version=$(VERSION) --define Path=$(EXECUTABLE_PATH) --output cloudflared-$(VERSION)-$(TARGET_ARCH).msi cloudflared.wxs
@@ -235,12 +231,8 @@ github-release-dryrun:
235231

236232
.PHONY: github-release
237233
github-release:
238-
python3 github_release.py --path $(PWD)/built_artifacts --release-version $(VERSION)
239-
python3 github_message.py --release-version $(VERSION)
240-
241-
.PHONY: gitlab-release
242-
gitlab-release:
243234
python3 github_release.py --path $(PWD)/artifacts/ --release-version $(VERSION)
235+
python3 github_message.py --release-version $(VERSION)
244236

245237
.PHONY: r2-linux-release
246238
r2-linux-release:

build-packages.sh

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)