-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
104 lines (97 loc) · 3.59 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
stages:
- prepare
- compiling
- assembling
- releasing
- publishing
image: passwords-builder
Prepare:
stage: prepare
script:
- PACKAGE_NAME=htmlviewer
- APP_ID=${PACKAGE_NAME}
- APP_NAME="Html Viewer"
- APP_VERSION=$(node -p "require('./package.json').version")
- if [ "${CI_COMMIT_REF_NAME}" != "stable" ] ; then APP_VERSION="${APP_VERSION}-build${CI_PIPELINE_ID}"; PACKAGE_NAME=${APP_ID}-nightly ; fi
- PACKAGE_REGISTRY_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGE_NAME}/${APP_VERSION}"
- CHANGELOG=$(node --no-warnings scripts/extract-changelog.mjs)
- echo "PACKAGE_NAME=${PACKAGE_NAME}" >> variables.env
- echo "APP_VERSION=${APP_VERSION}" >> variables.env
- echo "PACKAGE_REGISTRY_URL=${PACKAGE_REGISTRY_URL}" >> variables.env
- echo "CHANGELOG=${CHANGELOG}" >> variables.env
- echo "APP_NAME=${APP_NAME}" >> variables.env
- echo "APP_ID=${APP_ID}" >> variables.env
artifacts:
expire_in: 1 week
reports:
dotenv: variables.env
only:
- testing
- stable
Compile:
stage: compiling
script:
- npm ci
- npm run build
artifacts:
expire_in: 1 week
paths:
- ./js/*
only:
- testing
- stable
Assemble:
stage: assembling
script:
- mkdir ${PACKAGE_NAME}
- if [ "${CI_COMMIT_REF_NAME}" == "stable" ] ; then php scripts/set-version.php ; fi
- if [ "${CI_COMMIT_REF_NAME}" != "stable" ] ; then php scripts/set-version.php --nightly --build "${CI_PIPELINE_ID}" ; fi
- rsync -r appinfo ${APP_ID}
- rsync -r img ${APP_ID}
- rsync -r js ${APP_ID}
- rsync -r l10n ${APP_ID}
- rsync -r lib ${APP_ID}
- cp CHANGELOG.md ${APP_ID}/
- /usr/src/nextcloud/occ integrity:sign-app --path=$(pwd)/${APP_ID} --privateKey=${SIGN_KEY} --certificate=${SIGN_CRT}
- tar -zcf ${PACKAGE_NAME}.tar.gz ${APP_ID}
- SIGNATURE=$(openssl dgst -sha512 -sign ${SIGN_KEY} ./${PACKAGE_NAME}.tar.gz | openssl base64 | tr -d "\n")
- echo "SIGNATURE=${SIGNATURE}" >> variables.env
- PACKAGE_URL="${PACKAGE_REGISTRY_URL}/${PACKAGE_NAME}.tar.gz"
- echo "PACKAGE_URL=${PACKAGE_URL}" >> variables.env
- 'curl --retry 5 --retry-all-errors --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file ./${PACKAGE_NAME}.tar.gz "${PACKAGE_URL}"'
- echo "Package available at ${PACKAGE_URL}"
artifacts:
expire_in: 1 week
reports:
dotenv: variables.env
only:
- testing
- stable
Publish Package:
stage: publishing
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- echo -e "## New in ${APP_NAME} ${APP_VERSION}\\n${CHANGELOG}" > description.txt
- |
release-cli create --name "${APP_NAME} ${APP_VERSION}" --tag-name ${APP_VERSION} \
--description "description.txt" \
--assets-link "{\"name\":\"${APP_NAME} ${APP_VERSION} (tar.gz)\",\"url\":\"${PACKAGE_URL}\",\"link_type\":\"package\"}"
only:
- stable
Publish Nightly:
stage: publishing
script:
- 'curl --retry 3 --retry-all-errors -m 900 --connect-timeout 900 -f -X POST ${API_URL} -H "Authorization: Token ${API_TOKEN}" -H "Content-Type: application/json" -d "{\"download\":\"${PACKAGE_URL}\",\"signature\":\"${SIGNATURE}\",\"nightly\":true}"'
environment:
name: Testing
only:
- testing
- never
Publish Stable:
stage: publishing
script:
- 'curl --retry 3 --retry-all-errors -m 900 --connect-timeout 900 -f -X POST ${API_URL} -H "Authorization: Token ${API_TOKEN}" -H "Content-Type: application/json" -d "{\"download\":\"${PACKAGE_URL}\",\"signature\":\"${SIGNATURE}\",\"nightly\":false}"'
environment:
name: Stable
only:
- stable