-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
131 lines (101 loc) · 4.51 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
121
122
123
124
125
126
127
128
129
130
131
include:
- project: 'tuxedocomputers/development/gitlab-ci-scripts'
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 "tux@tuxedocomputers.com"
- gpg --import ${TUXEDO_BOT_GPG_PRIVATE_KEY}
# Setup author for dch.
- export DEBFULLNAME="Tuxedo BOT"
- export DEBEMAIL="tux@tuxedocomputers.com"
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
- notify
update:
stage: update
only:
# Don't run on every push, but only manually issued and periodically.
- web
- schedule
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.
- ./01-tuxedo-update-repository.sh --auto
# Push using a GitLab Personal Access Token.
- git push --force --progress --verbose "https://${TUXEDO_BOT_GITLAB_USERNAME}:${TUXEDO_BOT_GITLAB_CI_PERSONAL_ACCESS_TOKEN}@${CI_REPOSITORY_URL#*@}" ${CI_COMMIT_BRANCH}
- git push --force --progress --verbose "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:
# Deploy after new tag has been pushed.
- tags
variables:
# This job does not need a clean working directory.
GIT_STRATEGY: fetch
script:
# Get version number.
- CURRENT_VERSION=$(grep --perl-regexp --only-matching --max-count 1 '^linux-tuxedo-.*\(\K.*(?=\))' debian.tuxedo-*/changelog)
# Upload to new folder on internal Nextcould.
- curl --request MKCOL ${TUXEDO_BOT_WEBDAV_LINUX_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_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:
# Set variables for generic deploy script from CI include from the top
- USERNAME=${FLAT_APT_REPO_UPLOAD_USER}
- TARGETSERVER=${FLAT_APT_REPO_UPLOAD_URL}
- CURRENT_VERSION=$(grep -Pom1 '^linux-tuxedo-.*\(\K.*(?=\))' debian.tuxedo-*/changelog)
- 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
notify:
stage: notify
only:
# Notify after new tag has been pushed.
- tags
variables:
# This job does not need the git repository.
GIT_STRATEGY: none
script:
- curl --request POST --form token=${LINUX_META_CI_TRIGGER_TOKEN} --form ref=${LINUX_META_22_04_BRANCH_NAME} --form variables[NEW_KERNEL_TAG]=${CI_COMMIT_TAG} ${LINUX_META_CI_TRIGGER_URL}