-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
160 lines (146 loc) · 4.93 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
stages:
- prepare
- cargo_tests
- platform_build
- deploy
cache: &global_cache
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cargo/bin
- .cargo/registry/index
- .cargo/registry/home
- target
policy: pull-push
variables:
CACHE_HOME: ${CI_PROJECT_DIR}/.cargo
prepare:
stage: prepare
image: "rust:latest"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
script:
- echo LABT_VERSION=$(awk -F ' = ' '$1 ~ /^version$/ {gsub(/["]/, "", $2); print($2)}' Cargo.toml) > variables.env
- echo "PKG_REGISTRY_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic" >> variables.env
- cat variables.env
artifacts:
reports:
dotenv: variables.env
# Use cargo to test the project
cargo_test:
stage: cargo_tests
image: "rust:latest"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_TAG
before_script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends build-essential
script:
- rustc --version && cargo --version # Print version info for debugging
- cargo test --workspace --features vendored-lua
cache:
policy: pull
when: on_success
<<: *global_cache
# disable checking clippy for now
# test:clippy:
# image: "rust:latest"
# before_script:
# - apt-get update -yqq
# - apt-get install -yqq --no-install-recommends build-essential
# - rustup component add clippy
# script:
# - cargo clippy
# cache:
# policy: pull
# when: on_success
# <<: *global_cache
build_linux:
stage: platform_build
image: "rust:latest"
before_script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends build-essential
rules:
- if: $CI_COMMIT_TAG
script:
- echo "=== BUILDING FOR x86_64 linux gnu ==="
- rustup target add x86_64-unknown-linux-gnu
- cargo build --target=x86_64-unknown-linux-gnu --release --features vendored-lua
- mkdir bin
- ls -la
- ls -la target
- mv target/x86_64-unknown-linux-gnu/release/labt bin/labt_v${LABT_VERSION}_x86_64
artifacts:
paths:
- bin/
cache:
policy: pull-push
<< : *global_cache
build_windows:
stage: platform_build
image: "rust:latest"
before_script:
- apt-get update -yqq
- apt-get install -yqq --no-install-recommends build-essential gcc-mingw-w64
- apt-get install -yqq --no-install-recommends nsis zip
- wget https://nsis.sourceforge.io/mediawiki/images/7/7f/EnVar_plugin.zip
- unzip -j EnVar_plugin.zip Plugins/x86-unicode/EnVar.dll -d plugins
- rm EnVar_plugin.zip
rules:
- if: $CI_COMMIT_TAG
script:
- echo "=== BUILDING FOR x86_64 linux gnu ==="
- rustup target add x86_64-pc-windows-gnu
- cargo build --target=x86_64-pc-windows-gnu --release --features vendored-lua
- mkdir bin
- ls -a
- ls -a target
- mv target/x86_64-pc-windows-gnu/release/labt.exe labt.exe
- makensis -DVERSION=${LABT_VERSION} windows-installer.nsi
- mv labt.exe bin/labt_v${LABT_VERSION}_x86_64-windows.exe
- mv labt-v${LABT_VERSION}_x86_64_windows-installer.exe bin/
artifacts:
paths:
- bin/
cache:
policy: pull-push
<< : *global_cache
release_job:
stage: deploy
needs:
- prepare
- build_linux
- build_windows
image: registry.gitlab.com/gitlab-org/release-cli:latest
script: echo "=== CREATING RELEASE ==="
rules:
- if: $CI_COMMIT_TAG
release:
tag_name: "v${LABT_VERSION}"
description: "Lightweight Android Build tool (LABt) v${LABT_VERSION}"
ref: $CI_COMMIT_SHA
assets:
links:
- name: "labt_v${LABT_VERSION}_x86_64_linux"
url: "${PKG_REGISTRY_URL}/x86_64-unknown-linux-gnu/v${LABT_VERSION}/labt"
- name: "labt_v${LABT_VERSION}_x86_64_windows.exe"
url: "${PKG_REGISTRY_URL}/x86_64-pc-windows-gnu/v${LABT_VERSION}/labt.exe"
- name: "labt_v${LABT_VERSION}_x86_64_windows-installer.exe"
url: "${PKG_REGISTRY_URL}/x86_64-pc-windows-gnu/v${LABT_VERSION}/labt-installer.exe"
upload_job:
stage: deploy
image: curlimages/curl:latest
needs:
- prepare
- build_linux
- build_windows
rules:
- if: $CI_COMMIT_TAG
script:
- echo "=== UPLOADING ==="
- ls -a bin/
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/labt_v${LABT_VERSION}_x86_64 ${PKG_REGISTRY_URL}/x86_64-unknown-linux-gnu/v${LABT_VERSION}/labt'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/labt_v${LABT_VERSION}_x86_64-windows.exe ${PKG_REGISTRY_URL}/x86_64-pc-windows-gnu/v${LABT_VERSION}/labt.exe'
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file bin/labt-v${LABT_VERSION}_x86_64_windows-installer.exe ${PKG_REGISTRY_URL}/x86_64-pc-windows-gnu/v${LABT_VERSION}/labt-installer.exe'