-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
99 lines (92 loc) · 3.77 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
include: "https://gitlab.gnome.org/GNOME/citemplates/raw/master/flatpak/flatpak_ci_initiative.yml"
variables:
TARGET:
description: Defines the ci target, whether to build the app ("flatpak") or update its dependencies ("autoupdate").
value: "flatpak"
options:
- "flatpak"
- "autoupdate"
.vars-devel:
# defines variables for the flatpak builds
image: "quay.io/gnome_infrastructure/gnome-runtime-images:gnome-47"
variables:
MANIFEST_PATH: "org.gnome.gitlab.johannesjh.favagtk.json"
FLATPAK_MODULE: "favagtk"
APP_ID: "org.gnome.gitlab.johannesjh.favagtk"
RUNTIME_REPO: "https://nightly.gnome.org/gnome-nightly.flatpakrepo"
BUNDLE_x86_64: org.gnome.gitlab.johannesjh.favagtk.devel_x86_64.flatpak
BUNDLE_aarch64: org.gnome.gitlab.johannesjh.favagtk.devel_aarch64.flatpak
CONFIG_OPTS: >-
-Dprofile=devel
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/favagtk/${CI_COMMIT_TAG}"
flatpak@x86_64:
# builds a flatpak bundle for x86_64
rules:
- if: $TARGET == "flatpak"
extends: [".flatpak@x86_64", ".vars-devel"]
variables:
BUNDLE: ${BUNDLE_x86_64}
flatpak@aarch64:
# builds a flatpak bundle for aarch64
rules:
- if: $TARGET == "flatpak"
extends: [".flatpak@aarch64", ".vars-devel"]
variables:
BUNDLE: ${BUNDLE_aarch64}
upload:
# uploads the flatpak bundle to the project's package registry
# based on: https://gitlab.com/gitlab-org/release-cli/-/tree/master/docs/examples/release-assets-as-generic-package
extends: [".vars-devel"]
stage: deploy
rules:
- if: $TARGET == "flatpak" && $CI_COMMIT_TAG
image: curlimages/curl:latest
script:
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${BUNDLE_x86_64}" "${PACKAGE_REGISTRY_URL}/${BUNDLE_x86_64}"'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${BUNDLE_aarch64}" "${PACKAGE_REGISTRY_URL}/${BUNDLE_aarch64}"'
release:
# publishes a gitlab release when a tag has been pushed
# see also: https://docs.gitlab.com/ee/ci/yaml/index.html#release
extends: [".vars-devel"]
stage: deploy
needs:
- upload
rules:
- if: $TARGET == "flatpak" && $CI_COMMIT_TAG
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- echo "Running the release job."
release:
tag_name: $CI_COMMIT_TAG
name: "Release $CI_COMMIT_TAG"
description: "Release created using the release-cli."
assets:
links:
- name: ${BUNDLE_x86_64}
url: ${PACKAGE_REGISTRY_URL}/${BUNDLE_x86_64}
- name: ${BUNDLE_aarch64}
url: ${PACKAGE_REGISTRY_URL}/${BUNDLE_aarch64}
autoupdate:
# periodically submits a merge request with updated dependencies
# see https://stackoverflow.com/a/72743215
image: "python:3.11-bookworm"
rules:
- if: $TARGET == "autoupdate"
before_script:
- if [ -z ${AUTOUPDATE_PUSH_TOKEN} ]; then (echo "Error The variable AUTOUPDATE_PUSH_TOKEN is empty, but the token is needed to push updated dependencies using git." && exit 1); fi
- export BRANCH=autoupdate-`date -I`
- git remote set-url origin https://AUTOUPDATE_PUSH_TOKEN:${AUTOUPDATE_PUSH_TOKEN}@gitlab.gnome.org/johannesjh/favagtk.git
- git config user.name ${GITLAB_USER_NAME}
- git config user.email ${GITLAB_USER_EMAIL}
script:
- git branch -D ${BRANCH} || exit_code=$?
- git checkout -b ${BRANCH}
- pip install pip-tools pre-commit
- pre-commit install
- make -C requirements pip-compile
- make -C requirements python3-main.json
- git add requirements/*
- git status
- git diff --staged
- git commit -m 'autoupdate of python dependencies'
- git push --set-upstream origin ${BRANCH} -o merge_request.create -o merge_request.remove_source_branch -o merge_request.title="autoupdate of python dependencies" || exit_code=$?