-
Notifications
You must be signed in to change notification settings - Fork 214
/
.travis.yml
144 lines (137 loc) · 5.64 KB
/
.travis.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
# taskcat ci config version v2
# Python Versions
# Python: 3.7
#
# Create development builds (Triggered by commit to develop branch)
# - Builds pypi package to https://test.pypi.org/project/taskcat/
# - Tags development builds
#
dist: xenial
language: python
branches:
only:
- main
python:
- "3.7.2"
- "3.8"
before_install:
- pip install -r travis-specific-requirements.txt
- pip install -r dev-requirements.txt
- cd /tmp
- GIT_SECRETS_RELEASE=1.3.0
- wget https://github.com/awslabs/git-secrets/archive/${GIT_SECRETS_RELEASE}.tar.gz
- tar -xvf ${GIT_SECRETS_RELEASE}.tar.gz
- cd git-secrets-${GIT_SECRETS_RELEASE}/
- sudo make install
- cd ${TRAVIS_BUILD_DIR}
install:
- pip install .
script: pre-commit run --all-files
jobs:
include:
- stage: "[Version Bump] Check/Create Release PR"
name: "[Version Bump] Check/Create Release PR"
if: branch = main AND commit_message !~ /(Bump|Release taskcat)/ AND type = push
before_script:
- |
pip install bump2version
HUB_DIST=linux-amd64
HUB_VERSION=$(curl -w "%{url_effective}\n" -I -L -s -S github.com/github/hub/releases/latest -o /dev/null | awk -F'releases/tag/v' '{ print $2 }')
curl "https://github.com/github/hub/releases/download/v${HUB_VERSION}/hub-${HUB_DIST}-${HUB_VERSION}.tgz" -L | tar xvz && sudo ./hub-${HUB_DIST}-${HUB_VERSION}/install && rm -r ./hub-${HUB_DIST}-${HUB_VERSION}
- mkdir -p ~/.config/taskcat
- |
echo -e "github.com:\n- user: aws-ia-ci\n oauth_token: ${GHT}\n protocol: https" > ~/.config/hub
script:
- export RELEASE_ID=$(cut -f1-2 -d . VERSION)
- export ORIGINAL_VERSION=$(cat VERSION)
- git checkout "release/v${RELEASE_ID}" || git checkout -b "release/v${RELEASE_ID}"
- bumpversion --no-commit --allow-dirty --no-tag patch
- bumpversion --commit --allow-dirty --no-tag release --message "Bump Version - Creating a new minor version"
- export NEW_VERSION=$(cat VERSION)
- git push "https://${GHT}:@github.com/${TRAVIS_REPO_SLUG}" "release/v${RELEASE_ID}" --force || travis_terminate 1
- |
OPEN_PR=$(hub pr list -s open --base main --head "release/v${RELEASE_ID}" -L 1 -f "%I")
if [ -z "${OPEN_PR}" ]; then
hub pull-request -m "Release taskcat [${NEW_VERSION}]" -h "release/v${RELEASE_ID}"
fi
- |
OPEN_PR=$(hub pr list -s open --base main --head "release/v${RELEASE_ID}" -L 1 -f "%I")
LAST_RELEASE_COMMIT=$(git rev-list --tags --max-count=1)
TAG_BODY=$(git --no-pager log --no-merges --oneline ${LAST_RELEASE_COMMIT}..HEAD --pretty='- %h %s')
hub api -XPATCH repos/${TRAVIS_REPO_SLUG}/issues/${OPEN_PR} -f body="${TAG_BODY}"
- stage: "[Version Bump] Create PyPI Development release"
name: "[Version Bump] Create PyPI Development release"
if: branch = main AND type = push
before_script:
- pip install bump2version
- pip install packaging
- export UPSTREAM_PYPI_VERSION=$(python -c "from packaging import version; import requests; versions = requests.get('https://pypi.org/pypi/taskcat/json').json()['releases'].keys(); versions = [version.Version(x) for x in versions]; print(sorted(versions, reverse=True)[0])")
script:
- |
echo "${UPSTREAM_PYPI_VERSION}" | egrep -i '\.dev[0-9]{1,4}'
if [[ $? -eq 0 ]]; then
echo "Bumping the development version"
# Replacing VERSION (ex: 0.9.12) with upstream value (ex: 0.9.13.dev0)
sed -i -e "s,$(cat VERSION),${UPSTREAM_PYPI_VERSION},g" .bumpversion.cfg
sed -i -e "s,$(cat VERSION),${UPSTREAM_PYPI_VERSION},g" VERSION
# Now bumping 0.9.13.dev0 -> 0.9.13.dev1
bumpversion --allow-dirty --no-tag --no-commit build
export NEW_DEV_BUILD=true
else
# v0.9.0 -> v0.9.1.dev0
bumpversion --allow-dirty --no-tag --no-commit patch
fi
- cat VERSION
- |
if [[ "$(cat VERSION)" == "${UPSTREAM_PYPI_VERSION}" ]]; then
echo "Something went wrong when bumping the version. Exiting."
travis_terminate 1
fi
- |
egrep -i '\.dev[0-9]{1,4}' VERSION
if [[ $? -eq 1 ]]; then
echo "No .dev pre-release tag found in VERSION. Not building PYPI package"
travis_terminate 1
fi
deploy:
- provider: pypi
skip_cleanup: true
user: $PYPI_USER
password: $PYPI_PASSWORD
on:
branch: main
- stage: "Tag build changelog/Push pypi and github release/Update docs"
name: "Tag build changelog/Push pypi and github release/Update docs"
if: branch = main AND fork = false AND type = push
script:
- |
echo "${TRAVIS_COMMIT_MESSAGE}" | egrep -i 'Merge pull request.*from aws-ia/release.*$'
if [[ $? -eq 0 ]]; then
LAST_RELEASE_COMMIT=$(git rev-list --tags --max-count=1)
TAG_BODY=$(git --no-pager log --no-merges --oneline ${LAST_RELEASE_COMMIT}..HEAD --pretty='- %h %s')
git tag -a "$(cat VERSION)" -m "${TAG_BODY}"
git push --tags "https://$GHT:@github.com/$TRAVIS_REPO_SLUG"
export RELEASE_THE_KRAKEN=true
fi
deploy:
- provider: releases
skip_cleanup: true
api_key: "$GHT"
file: directory/*
on:
branch: main
fork: false
condition: $RELEASE_THE_KRAKEN = true
- provider: pypi
skip_cleanup: true
user: $PYPI_USER
password: $PYPI_PASSWORD
on:
branch: main
fork: false
condition: $RELEASE_THE_KRAKEN = true
# Add Docker provider
cache:
directories:
- $HOME/.cache/pip
- $HOME/.cache/pre-commit