-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
94 lines (88 loc) · 4.87 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
stages:
- build
- upload-gitlab-registry
- release-gitlab
- release-s3
variables:
PACKAGE_REGISTRY_URL: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/osmflux/${CI_COMMIT_TAG}'
CI_RELEASE_CHANNEL: 'dev'
before_script:
- |
if [[ "$CI_COMMIT_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Current tag is for the stable release"
CI_RELEASE_CHANNEL="stable"
else
echo "Current tag is for the non-stable release, checking tag format..."
if [[ ! "$CI_COMMIT_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+-mr[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: Tag format for non-stable release is incorrect. It should be in the format: 1.0.0-mr5.1, that's 3 digital parts, dash, 'mr' and merge request ID, dot, build sequence"
exit 1
fi
fi
build:
stage: build
image: node:18-bookworm
only:
- tags
script:
- npm i -g @neutralinojs/neu
- yarn
- yarn release $CI_RELEASE_CHANNEL
artifacts:
name: '$CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-$CI_JOB_NAME'
paths:
- dist/
- commands/
upload-gitlab-registry:
stage: upload-gitlab-registry
image: curlimages/curl:latest
only:
- tags
script:
- |
if [[ ! "$CI_RELEASE_CHANNEL" == "stable" ]]; then
echo "non-stable release, skip this step"
exit 0
fi
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/archives/osmflux-darwin-arm64.app.zip ${PACKAGE_REGISTRY_URL}/osmflux-darwin-arm64.app.zip'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/archives/osmflux-darwin-x64.app.zip ${PACKAGE_REGISTRY_URL}/osmflux-darwin-x64.app.zip'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/archives/osmflux-linux-arm64.zip ${PACKAGE_REGISTRY_URL}/osmflux-linux-arm64.zip'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/archives/osmflux-linux-x64.zip ${PACKAGE_REGISTRY_URL}/osmflux-linux-x64.zip'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/archives/osmflux-windows-x64.zip ${PACKAGE_REGISTRY_URL}/osmflux-windows-x64.zip'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/osmflux/resources.neu ${PACKAGE_REGISTRY_URL}/resources.neu'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file dist/update_manifest.json ${PACKAGE_REGISTRY_URL}/update_manifest.json'
release-gitlab:
stage: release-gitlab
image: registry.gitlab.com/gitlab-org/release-cli:latest
only:
- tags
script:
- |
if [[ ! "$CI_RELEASE_CHANNEL" == "stable" ]]; then
echo "non-stable release, skip this step"
exit 0
fi
- |
release-cli create --name "$CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"osmflux-darwin-arm64.app.zip\", \"url\":\"${PACKAGE_REGISTRY_URL}/osmflux-darwin-arm64.app.zip\", \"link_type\": \"package\"}" \
--assets-link "{\"name\":\"osmflux-darwin-x64.app.zip\", \"url\":\"${PACKAGE_REGISTRY_URL}/osmflux-darwin-x64.app.zip\", \"link_type\": \"package\"}" \
--assets-link "{\"name\":\"osmflux-linux-arm64.zip\", \"url\":\"${PACKAGE_REGISTRY_URL}/osmflux-linux-arm64.zip\", \"link_type\": \"package\"}" \
--assets-link "{\"name\":\"osmflux-linux-x64.zip\", \"url\":\"${PACKAGE_REGISTRY_URL}/osmflux-linux-x64.zip\", \"link_type\": \"package\"}" \
--assets-link "{\"name\":\"osmflux-windows-x64.zip\", \"url\":\"${PACKAGE_REGISTRY_URL}/osmflux-windows-x64.zip\", \"link_type\": \"package\"}" \
--assets-link "{\"name\":\"resources.neu\", \"url\":\"${PACKAGE_REGISTRY_URL}/resources.neu\"}" \
--assets-link "{\"name\":\"update_manifest.json\", \"url\":\"${PACKAGE_REGISTRY_URL}/update_manifest.json\"}"
release-s3:
stage: release-s3
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
only:
- tags
script:
- mkdir -p ~/.aws
- cp $CI_AWS_CONFIG ~/.aws/config
- cp $CI_AWS_CREDENTIALS ~/.aws/credentials
- aws s3 --endpoint-url=$CI_AWS_ENDPOINT_URL cp --recursive dist/archives/ s3://$CI_S3_BUCKET/osmflux/releases/$CI_RELEASE_CHANNEL/$CI_COMMIT_TAG/
- aws s3 --endpoint-url=$CI_AWS_ENDPOINT_URL cp dist/update_manifest.json s3://$CI_S3_BUCKET/osmflux/releases/$CI_RELEASE_CHANNEL/$CI_COMMIT_TAG/
- aws s3 --endpoint-url=$CI_AWS_ENDPOINT_URL cp dist/osmflux/resources.neu s3://$CI_S3_BUCKET/osmflux/releases/$CI_RELEASE_CHANNEL/$CI_COMMIT_TAG/
- aws s3 --endpoint-url=$CI_AWS_ENDPOINT_URL cp --recursive dist/archives/ s3://$CI_S3_BUCKET/osmflux/releases/$CI_RELEASE_CHANNEL/latest/
- aws s3 --endpoint-url=$CI_AWS_ENDPOINT_URL cp dist/update_manifest.json s3://$CI_S3_BUCKET/osmflux/releases/$CI_RELEASE_CHANNEL/latest/
- aws s3 --endpoint-url=$CI_AWS_ENDPOINT_URL cp dist/osmflux/resources.neu s3://$CI_S3_BUCKET/osmflux/releases/$CI_RELEASE_CHANNEL/latest/
- aws s3 --endpoint-url=$CI_AWS_ENDPOINT_URL cp --recursive commands/ s3://$CI_S3_BUCKET/osmflux/releases/$CI_RELEASE_CHANNEL/latest/commands/