-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
100 lines (94 loc) · 2.5 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
stages:
- update
- build
- release
- container
variables:
GIT_STRATEGY: clone
GIT_CLEAN_FLAGS: none
NIXPKGS_ALLOW_UNFREE: 1
NAME:
value: ""
description: "Package name to update and build"
VERSION:
value: ""
description: "Version of the package"
update::version:
stage: update
image: local
rules:
- if: $CI_PIPELINE_SOURCE == "api"
tags:
- nix
script:
- if [ -f "${NAME}"/default.nix ]; then export CURR_VERSION=$(cat ./${NAME}/default.nix|awk -F'"' '/version =/ {print $2;} ') ; fi
- |
echo "New version : ${VERSION} for ${NAME}"
if [ "${CURR_VERSION}" == "${VERSION}" ]
then
echo "Version matched doing nothing"
else
echo "Version mismatch updating..."
if [ -f "${NAME}/update.sh" ]
then
./${NAME}/update.sh || true
else
sed -i "s/version = \"${CURR_VERSION}/version = \"${VERSION}/g" ${NAME}/default.nix
fi
fi
artifacts:
paths:
- ${NAME}/
expire_in: '600'
build::package:
stage: build
image: local
rules:
- if: $CI_PIPELINE_SOURCE == "api"
dependencies:
- update::version
tags:
- nix
script:
- cat ${NAME}/default.nix
- nix build .#${NAME}
release::package:
stage: release
image: local
dependencies:
- update::version
rules:
- if: $CI_PIPELINE_SOURCE == "api"
tags:
- nix
script:
- git config --global user.email "[email protected]"
- git config --global user.name "Abott"
- git config --global "http.${CI_SERVER_URL}.sslCAInfo" "$CI_SERVER_TLS_CA_FILE"
- git add ${NAME}
- git commit -m "Releasing new version ${VERSION} for ${NAME} [skip ci]" || echo "No changes, nothing to commit!"
- git remote add gitlab_origin https://oauth2:[email protected]/thomas/nix.git
- git push gitlab_origin HEAD:main
- git clone https://oauth2:[email protected]/docker/${NAME}.git docker-${NAME}
- cd docker-${NAME}
- |
if ! [ $(git tag | grep ${VERSION}) ]
then
git tag -a ${VERSION} -m "Update to version ${VERSION} from $CI_COMMIT_SHORT_SHA"
git push origin ${VERSION}
else
echo "Tag already exist"
fi
#build::docker:
# stage: container
# image: local
# dependencies:
# - release::package
# tags:
# - nix
# rules:
# - if: $CI_PIPELINE_SOURCE == "api"
# - exists:
# - ${NAME}/docker.nix
# script:
# - nix-shell --run ./build.sh