-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
87 lines (76 loc) · 2.43 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
image: sammy8806/python-alpine-git
variables:
PYPI_REPO_URL_TEST: https://test.pypi.org/legacy/
PYPI_REPO_URL_LIVE: https://pypi.org/legacy/
PYPI_REPO_TARGET: LIVE
stages:
- mirror
- deploy
- cleanup
mirror_github:
stage: mirror
variables:
GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${CI_PROJECT_DIR}/.ssh/id_rsa"
GITHUB_URL: "git@github.com:sammy8806/pyFloatplane.git"
TEMP_BRANCH: "pushMe"
before_script:
- mkdir -p ${CI_PROJECT_DIR}/.ssh
- echo "$DEPLOY_KEY" > ${CI_PROJECT_DIR}/.ssh/id_rsa
- chmod 0600 ${CI_PROJECT_DIR}/.ssh/id_rsa
- git remote remove github 2>/dev/null || true
- git remote add github $GITHUB_URL
# BEGIN https://cmatskas.com/merge-detached-head-back-to-originmaster-git/
- git checkout -b $TEMP_BRANCH #makes a new branch from current detached HEAD
- git branch -f $CI_COMMIT_REF_NAME $TEMP_BRANCH #update master to point to the new <temp> branch
#- git branch -d $TEMP_BRANCH #delete the <temp> branch
- git push github $CI_COMMIT_REF_NAME #push the re-established history
# END
- echo Git Debug
- echo GITHUB_URL = $GITHUB_URL
- echo CI_COMMIT_REF_NAME = $CI_COMMIT_REF_NAME
- git rev-parse HEAD
- git ls-remote $GITHUB_URL
- git status
script:
- git push github $CI_COMMIT_REF_NAME --force
- git push github $CI_COMMIT_REF_NAME --force --tags
after_script:
- git remote remove github
- rm -vf ${CI_PROJECT_DIR}/.ssh/*
only:
- master
mirror_cleanup:
stage: mirror
when: always
script:
- rm -vf ${CI_PROJECT_DIR}/.ssh/* || true
only:
- master
deploy_pypi:
stage: deploy
variables:
script:
- echo "[uploadtarget]" >> ~/.pypirc
- export REPO_URL=PYPI_REPO_URL_${PYPI_REPO_TARGET}
- echo $REPO_URL
- export PYPI_PASSWORD_NAME=PYPI_PASSWORD_${PYPI_REPO_TARGET}
- echo $PYPI_PASSWORD_NAME
- echo "repository:" ${!REPO_URL} >> ~/.pypirc
- echo "username:" ${PYPI_USER} >> ~/.pypirc
- echo "password:" ${!PYPI_PASSWORD_NAME} >> ~/.pypirc
- cat ~/.pypirc | grep -v password
- python setup.py check sdist bdist upload -r uploadtarget
- echo "" > ~/.pypirc && rm ~/.pypirc
only:
- /^v\d+\.\d+\.\d+([abc]\d*)?$/ # PEP-440 compliant
except:
- branches
cleanup_deploy:
stage: cleanup
when: always
script:
- rm -vf ~/.pypirc
only:
- /^v\d+\.\d+\.\d+([abc]\d*)?$/ # PEP-440 compliant
except:
- branches