-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
120 lines (93 loc) · 4.38 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
include:
- project: 'tuxedocomputers/development/gitlab-ci-scripts'
ref: kernel-ci-22.04
file: '/common-deploy.yml'
default:
# Custom docker image: ubuntu:jammy with build dependencies preinstalled.
image: linux-builder-jammy
before_script:
# Configure git to be able to push.
- git config --global user.name "Tuxedo BOT"
- git config --global user.email "[email protected]"
- gpg --import ${TUXEDO_BOT_GPG_PRIVATE_KEY}
# Setup author for dch.
- export DEBFULLNAME="Tuxedo BOT"
- export DEBEMAIL="[email protected]"
# Set token based checkout url for the internal gitlab repository, this and the public
# github repository are 1 to 1 mirrors on all branches used here.
- export LINUX_REPO_URL="https://${TUXEDO_BOT_GITLAB_USERNAME}:${TUXEDO_BOT_GITLAB_CI_PERSONAL_ACCESS_TOKEN}@${LINUX_REPO_CLONE_URL_HTTPS#https://}"
variables:
# Create a fresh clone every time, instead of caching the last checkout of the repository. This
# is required for a clean slate the way the auto-update script expects.
GIT_STRATEGY: clone
stages:
# The update job is not run on the same commit as the build, and deploy jobs. It's included in
# this explicit order here purely to make the CI script more readable.
- update
- build
- deploy
update:
stage: update
only:
# Don't run on every push, but only manually issued and periodically.
- web
- schedule
- trigger
script:
# GitLab CI checks out in a detached head state, correct this to be able to push.
- git checkout ${CI_COMMIT_BRANCH}
# Run the logic determining the new version, update, and push the result.
- ./auto-update ${NEW_KERNEL_TAG}
# Push using a GitLab Personal Access Token.
- git push "https://${TUXEDO_BOT_GITLAB_USERNAME}:${TUXEDO_BOT_GITLAB_CI_PERSONAL_ACCESS_TOKEN}@${CI_REPOSITORY_URL#*@}" ${CI_COMMIT_BRANCH}
- git push "https://${TUXEDO_BOT_GITLAB_USERNAME}:${TUXEDO_BOT_GITLAB_CI_PERSONAL_ACCESS_TOKEN}@${CI_REPOSITORY_URL#*@}" $(git describe --tags --abbrev=0)
build:
stage: build
only:
# Build after new tag has been pushed.
- tags
script:
# Setup environment and create packages.
- LANG=C fakeroot debian/rules clean
- LANG=C debuild --no-tgz-check
# Copy results into build directory so that the artifacts keyword can pick them up.
- rm --recursive --force output
- mkdir output
- mv ../*.deb ../*.udeb ../*.build ../*.buildinfo ../*.changes ../*.tar.gz ../*.dsc output || true
artifacts:
# Save build results.
paths:
- output
deploy_to_nextcloud:
stage: deploy
only:
# Build after new tag has been pushed.
- tags
script:
# Get version number.
- CURRENT_VERSION=$(grep --perl-regexp --only-matching --max-count 1 '(?<=^linux-meta-tuxedo-22\.04 \().*(?=\))' debian/changelog)
# Upload to new folder on internal Nextcould.
- curl --request MKCOL ${TUXEDO_BOT_WEBDAV_LINUX_META_22_04_BASE_FOLDER_URL}/${CURRENT_VERSION} --user ${TUXEDO_BOT_NEXTCLOUD_USERNAME}:${TUXEDO_BOT_NEXTCLOUD_PASSWORD}
- find output/* -exec curl -T '{}' ${TUXEDO_BOT_WEBDAV_LINUX_META_22_04_BASE_FOLDER_URL}/${CURRENT_VERSION}/ --user ${TUXEDO_BOT_NEXTCLOUD_USERNAME}:${TUXEDO_BOT_NEXTCLOUD_PASSWORD} \;
# Needs to be called "deploy" to use the CI include from the top
deploy: # deploy_to_flat_apt_repo
stage: deploy
# Overwrite "- when: never" rule from include
rules:
- if: $CI_COMMIT_TAG
when: on_success
- when: never
variables:
# This job does not need a clean working directory.
GIT_STRATEGY: fetch
before_script:
# Get version number.
- CURRENT_VERSION=$(grep --perl-regexp --only-matching --max-count 1 '(?<=^linux-meta-tuxedo-22\.04 \().*(?=\))' debian/changelog)
# Set variables for generic deploy script from CI include from the top
- USERNAME=${FLAT_APT_REPO_UPLOAD_USER}
- TARGETSERVER=${FLAT_APT_REPO_UPLOAD_URL}
- TARGETDIR=${FLAT_APT_REPO_UPLOAD_PATH_22_04}/${CURRENT_VERSION}
# Create flat apt repository meta information
- cd output
- dpkg-scanpackages . /dev/null | xz -9 > Packages.xz
# "script:" is implemented in CI include from the top