11stages :
22 - build
3- - deploy
4- - release_draft
5- - release_submit
3+ - private_deploy
4+ - public_deploy
65
76image : ${CI_DOCKER_REGISTRY}/esp32-ci-env
87
98variables :
109 ARCHIVE_DIR : " dist"
1110 ORIGIN_NAME : " com.espressif.idf.update-1.0.0-SNAPSHOT.zip"
1211
12+ .add_gh_key_remote : &add_gh_key_remote |
13+ cit_add_ssh_key "${GH_PUSH_KEY}"
14+ git remote remove github || true
15+ git remote add github ${GH_PUSH_REPO}
16+
1317before_script :
1418 # Use CI Tools
1519 - curl -sSL ${CIT_LOADER_URL} | sh
1620 - source citools/import_functions
17- # Use an unique name for the archive
18- - UNIQ_SUFFIX="g$(git describe --always --tags --dirty --abbrev=8)"
19- - ARCHIVE_NAME=${ORIGIN_NAME/SNAPSHOT/$UNIQ_SUFFIX}
20-
21- .add_gh_remote_key : &add_gh_remote_key |
22- cit_add_ssh_key "${GH_SSH_KEY}"
23- git remote remove gh || true
24- git remote add gh ${GH_PUSH_REPO}
25-
26- .release_tag_filter : &release_tag_filter
27- only :
28- - /^v[0-9].*$/
29-
30- .release_submit_action : &release_submit_action
31- when : manual
32- allow_failure : true
3321
3422build :
3523 stage : build
@@ -40,16 +28,90 @@ build:
4028 paths :
4129 - ${ARCHIVE_DIR}/
4230 expire_in : 2 weeks
43- variables :
44- GIT_STRATEGY : fetch
4531 script :
32+ # Use an unique name for the archive
33+ - UNIQ_SUFFIX="$(git describe --dirty --abbrev=8)"
34+ - mkdir -p ${ARCHIVE_DIR} && echo "${UNIQ_SUFFIX}" > ${ARCHIVE_DIR}/uniq_suffix_value
35+ - ARCHIVE_NAME=${ORIGIN_NAME/1.0.0-SNAPSHOT/$UNIQ_SUFFIX}
36+ # build
4637 - export JARSIGNER_KEYSTORE_B64=${JARSIGNER_REL_KEYSTORE_B64:-${JARSIGNER_DEV_KEYSTORE_B64}}
4738 - export JARSIGNER_STOREPASS=${JARSIGNER_REL_STOREPASS:-${JARSIGNER_DEV_STOREPASS}}
4839 - export JARSIGNER_ALIAS=${JARSIGNER_REL_ALIAS:-${JARSIGNER_DEV_ALIAS}}
4940 - KEYSTORE_FILE="${PWD}/${JARSIGNER_KEYSTORE}"
5041 - printf "%s" "${JARSIGNER_KEYSTORE_B64}" | base64 -d --ignore-garbage - > "${KEYSTORE_FILE}"
5142 - mvn -e -X clean install -Djarsigner.keystore="${KEYSTORE_FILE}" -Djarsigner.alias="${JARSIGNER_ALIAS}" -Djarsigner.storepass="${JARSIGNER_STOREPASS}"
5243 - rm -v "${KEYSTORE_FILE}"
53- - mkdir -p ${ARCHIVE_DIR}
54- - mv -v releng/com.espressif.idf.update/target/${ORIGIN_NAME} ${ARCHIVE_DIR}/${ARCHIVE_NAME}
44+ - mkdir -p ${ARCHIVE_DIR} && mv -v releng/com.espressif.idf.update/target/${ORIGIN_NAME} ${ARCHIVE_DIR}/${ARCHIVE_NAME}
5545 - ls -l ${ARCHIVE_DIR}
46+
47+ .upload_template : &upload_template
48+ when : manual
49+ tags :
50+ - deploy
51+ dependencies :
52+ - build
53+ script :
54+ # getting the corresponding unique suffix
55+ - UNIQ_SUFFIX=$(cat ${ARCHIVE_DIR}/uniq_suffix_value)
56+ - ARCHIVE_NAME=${ORIGIN_NAME/1.0.0-SNAPSHOT/$UNIQ_SUFFIX}
57+ # upload archive
58+ - cit_add_ssh_key "${SRV_KEY}"
59+ - cd ${ARCHIVE_DIR}
60+ - scp ${ARCHIVE_NAME} ${SRV_UPLOAD_PATH}
61+ # upload directory
62+ - UNIQ_DIR=${UNIQ_SUFFIX}
63+ - mkdir ${UNIQ_DIR} && cd ${UNIQ_DIR} && unzip -q ../${ARCHIVE_NAME} && cd ..
64+ - scp -r ${UNIQ_DIR} ${SRV_UPLOAD_PATH}
65+ - ssh ${SRV_SERVER_SSH} "cd ${SRV_DIR} && ln -srnf ${UNIQ_DIR} ${SRV_LATEST_NAME}"
66+ # Show info
67+ - echo -e "\nAn archives was published there:\n\n${SRV_HTTP_URL}/${ARCHIVE_NAME}"
68+ - echo -e "\n\n\nThe plugin was published there:\n\n${SRV_HTTP_URL}/${SRV_LATEST_NAME}"
69+
70+ internal_http :
71+ << : *upload_template
72+ stage : private_deploy
73+ variables :
74+ GIT_STRATEGY : none
75+ SRV_KEY : ${INTRNL_KEY}
76+ SRV_DIR : ${INTRNL_SERVER_CD_DIR}
77+ SRV_SERVER_SSH : ${INTRNL_SERVER_SSH}
78+ SRV_UPLOAD_PATH : ${INTRNL_SERVER_SSH}:${SRV_DIR}
79+ SRV_LATEST_NAME : latest
80+ SRV_HTTP_URL : ${INTRNL_SERVER_HTTP}
81+
82+ public_http :
83+ << : *upload_template
84+ stage : public_deploy
85+ only :
86+ - /^v[0-9].*$/
87+ variables :
88+ GIT_STRATEGY : none
89+ SRV_KEY : ${DL_KEY}
90+ SRV_DIR : " ${DL_SERVER_CD_DIR}"
91+ SRV_SERVER_SSH : ${DL_SERVER_SSH}
92+ SRV_UPLOAD_PATH : ${DL_SERVER_SSH}:${SRV_DIR}
93+ SRV_LATEST_NAME : latest
94+ SRV_HTTP_URL : ${DL_SERVER_HTTP}/${SRV_DIR}
95+
96+ .git_sync_template : &git_sync_template
97+ stage : public_deploy
98+ when : manual
99+ tags :
100+ - deploy
101+ dependencies : []
102+
103+ push_master_to_github :
104+ << : *git_sync_template
105+ only :
106+ - master
107+ script :
108+ - *add_gh_key_remote
109+ - git push github "${CI_COMMIT_SHA}:${CI_COMMIT_REF_NAME}"
110+
111+ push_tag_to_github :
112+ << : *git_sync_template
113+ only :
114+ - /^v[0-9].*$/
115+ script :
116+ - *add_gh_key_remote
117+ - git push github "${CI_COMMIT_TAG}"
0 commit comments