forked from wwjjbb/Luna-II
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
108 lines (98 loc) · 3.05 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
# https://docs.gitlab.com/ee/ci/yaml/index.html
stages:
- prepare
- version
- build
- upload
- release
variables:
PACKAGE_VERSION: "0.0.0"
prepare-tag:
stage: prepare
rules:
- if: $CI_COMMIT_TAG
script:
- echo "This is the 'prepare-tag' script"
- export PACKAGE_VERSION=${CI_COMMIT_TAG#v}
- echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> build.env
artifacts:
reports:
dotenv: build.env
prepare-tagless:
stage: prepare
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH
script:
- echo "This is the 'prepare-tagless' script"
- echo "Installing dependencies..."
- apk add git
- git fetch --tags
- |
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
LATEST_VERSION=${LATEST_TAG#v}
VERSION_BASE=${LATEST_VERSION%.[0-9]*}
LATEST_REVISION=${LATEST_VERSION##[0-9]*.}
if [ -z ${LATEST_REVISION##*-rc[0-9]*} ]; then
REVISION_BASE=${LATEST_REVISION%-rc[0-9]*}
REVISION_EXTENSION=${LATEST_REVISION#[0-9]*-rc}
REVISION=${REVISION_BASE}-rc$((${REVISION_EXTENSION}+1))
else
REVISION=$((${LATEST_REVISION}+1))-rc0
fi
PACKAGE_VERSION=${VERSION_BASE}.${REVISION}
- echo ${PACKAGE_VERSION}
- echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> build.env
artifacts:
reports:
dotenv: build.env
version:
stage: version
script:
- export PACKAGE_TAG=v${PACKAGE_VERSION}
- export PACKAGE_BINARY=Luna3-${PACKAGE_VERSION}.plasmoid
- echo "PACKAGE_TAG=${PACKAGE_TAG}" >> build.env
- echo "PACKAGE_BINARY=${PACKAGE_BINARY}" >> build.env
- echo "PACKAGE_REGISTRY_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/Luna3/${PACKAGE_TAG}" >> build.env
artifacts:
reports:
dotenv: build.env
build-job:
stage: build
artifacts:
name: "${PACKAGE_BINARY}"
paths:
- ${PACKAGE_BINARY}
script:
- echo "Installing dependencies..."
- apk add libplasma-dev g++ make cmake extra-cmake-modules zip bash
- echo "Configuring the code..."
- |
sed -Ei 's/"Version": "[0-9.]+",/"Version": "'"${PACKAGE_VERSION}"'",/' package/metadata.json
- echo "Compiling the code..."
- make plasmoid
- echo "Compile complete."
deploy-job:
stage: upload
environment: production
script:
- echo "Installing dependencies..."
- apk add curl
- echo "Deploying application..."
- |
curl --location --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file ${PACKAGE_BINARY} \
"${PACKAGE_REGISTRY_URL}/${PACKAGE_BINARY}"
- echo "Application successfully deployed."
release:
# Caution, as of 2021-02-02 these assets links require a login, see:
# https://gitlab.com/gitlab-org/gitlab/-/issues/299384
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
script:
- |
release-cli create --name "Release ${PACKAGE_TAG}" --tag-name ${PACKAGE_TAG} \
--assets-link "{\"name\":\"${PACKAGE_BINARY}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${PACKAGE_BINARY}\"}"