Skip to content

Commit ae554dd

Browse files
committed
ci: github upload helper
1 parent 65ed48e commit ae554dd

File tree

1 file changed

+44
-25
lines changed

1 file changed

+44
-25
lines changed

.gitlab-ci.yml

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ stages:
22
- build
33
- private_deploy
44
- test
5+
- public_deploy
56

67
image: ${CI_DOCKER_REGISTRY}/llvm-build:2
78

@@ -25,6 +26,8 @@ variables:
2526
UNARCHIVE_TOOL_WIN: "unzip"
2627
ARCHIVE_EXT_WIN: "zip"
2728

29+
DIST_DIR: "dist"
30+
2831
.use_ci_tools: &use_ci_tools |
2932
curl -sSL ${CIT_LOADER_URL} -o cit_loader.sh && sh cit_loader.sh
3033
source citools/import_functions
@@ -36,6 +39,15 @@ before_script:
3639
- *use_ci_tools
3740
- *add_gitlab_key
3841

42+
.build_template:
43+
stage: build
44+
tags: [ "amd64", "build" ]
45+
artifacts:
46+
paths:
47+
- ${DIST_DIR}/
48+
when: always
49+
expire_in: 10 day
50+
3951
# Prepare release name/number
4052
.get_release_name: &get_release_name |
4153
# using annotated tags
@@ -72,37 +84,25 @@ before_script:
7284
echo "${ARCHIVE_NAME}" > ${DIST_DIR}/file_${PLATFORM_NAME}_${CONF_TARGET}
7385

7486
build_clang_toolchain_linux:
75-
stage: build
76-
artifacts:
77-
paths:
78-
- dist_linux/
79-
when: always
80-
expire_in: 10 day
87+
extends: .build_template
8188
script:
8289
- ARCHIVE_TOOL=${ARCHIVE_TOOL_LINUX}
8390
- UNARCHIVE_TOOL=${UNARCHIVE_TOOL_LINUX}
8491
- ARCHIVE_EXT=${ARCHIVE_EXT_LINUX}
8592
- PLATFORM_NAME=${PLATFORM_NAME_LINUX}
86-
- DIST_DIR="dist_linux"
8793
- *get_release_name
8894
- *get_gcc_toolchain_linux
8995
- *get_clang_toolchain_build_scripts
9096
- ./build-toolchain-linux.sh ${XTENSA_CLANG_TOOLCHAIN}
9197
- *package_toolchain
9298

9399
build_clang_toolchain_win:
94-
stage: build
95-
artifacts:
96-
paths:
97-
- dist_win/
98-
when: always
99-
expire_in: 10 day
100+
extends: .build_template
100101
script:
101102
- ARCHIVE_TOOL=${ARCHIVE_TOOL_WIN}
102103
- UNARCHIVE_TOOL=${UNARCHIVE_TOOL_WIN}
103104
- ARCHIVE_EXT=${ARCHIVE_EXT_WIN}
104105
- PLATFORM_NAME=${PLATFORM_NAME_WIN}
105-
- DIST_DIR="dist_win"
106106
- *get_release_name
107107
- *get_gcc_toolchain_win
108108
- *get_clang_toolchain_build_scripts
@@ -111,6 +111,7 @@ build_clang_toolchain_win:
111111

112112
testsuite:
113113
stage: test
114+
tags: [ "amd64", "build" ]
114115
dependencies:
115116
- build_clang_toolchain_linux
116117
script:
@@ -119,7 +120,7 @@ testsuite:
119120
- ARCHIVE_EXT=${ARCHIVE_EXT_LINUX}
120121
- PLATFORM_NAME=${PLATFORM_NAME_LINUX}
121122
- *get_release_name
122-
- ${UNARCHIVE_TOOL} dist_linux/${ARCHIVE_NAME}
123+
- ${UNARCHIVE_TOOL} ${DIST_DIR}/${ARCHIVE_NAME}
123124

124125
# getting testsuit
125126
- git clone -b feature/ci_llvm_multitarget --depth 1 $GITLAB_SSH_SERVER/idf/llvm-xtensa-testsuite.git
@@ -146,16 +147,34 @@ upload_to_http:
146147
- *use_ci_tools
147148
script:
148149
- cit_add_ssh_key "${HTTP_UPLOAD_KEY}"
149-
# List of archives in dist_linux/
150-
- FILES=$(find dist_linux -name file_\* -exec cat {} \+)
151-
- cd dist_linux
152-
- scp ${FILES} ${HTTP_UPLOAD_DIR}/ct-ng/llvm-builds
153-
# Show info
154-
- echo -e "\nArchives were published there:\n\n$(for n in ${FILES}; do echo "${HTTP_PUBLIC_DIR}/ct-ng/llvm-builds/${n}"; done)\n"
155-
- cd ..
156-
# List of archives in dist_win/
157-
- FILES=$(find dist_win -name file_\* -exec cat {} \+)
158-
- cd dist_win
150+
# List of archives
151+
- FILES=$(find ${DIST_DIR} -name file_\* -exec cat {} \+)
152+
- cd ${DIST_DIR}
159153
- scp ${FILES} ${HTTP_UPLOAD_DIR}/ct-ng/llvm-builds
160154
# Show info
161155
- echo -e "\nArchives were published there:\n\n$(for n in ${FILES}; do echo "${HTTP_PUBLIC_DIR}/ct-ng/llvm-builds/${n}"; done)\n"
156+
157+
upload_to_github:
158+
stage: public_deploy
159+
when: manual
160+
allow_failure: true
161+
only:
162+
- tags
163+
tags: [ "amd64", "internet" ]
164+
image: espressif/github-hub:2
165+
variables:
166+
GIT_STRATEGY: fetch
167+
GITHUB_TOKEN: "${GH_TOKEN}"
168+
GITHUB_REPO: "${GH_REPO_HTTPS}"
169+
TAG: "${CI_COMMIT_TAG}"
170+
before_script: []
171+
script:
172+
- ls -l dist*/
173+
- git remote add github ${GH_REPO_HTTPS}
174+
- hub release show ${TAG} || { echo "Please create a release on GitHub with ${TAG} tag at first"; exit 1; }
175+
# List of archives
176+
- FILES=$(find ${DIST_DIR} -name file_\* -exec cat {} \+)
177+
- cd ${DIST_DIR}
178+
- ls -l $FILES
179+
# Upload archives
180+
- for n in ${FILES}; do hub release edit -m "" -a "${n}" "${TAG}"; done

0 commit comments

Comments
 (0)