-
Notifications
You must be signed in to change notification settings - Fork 42
/
codemagic.yaml
134 lines (131 loc) · 4.15 KB
/
codemagic.yaml
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
definitions:
cache: &cache
cache_paths:
- $CM_BUILD_DIR/.venv
artifacts: &artifacts
- dist/codemagic*.whl
- dist/codemagic*.tar.gz
scripts:
- &install_dependencies
name: Install dependencies
script: |
curl -sSL https://install.python-poetry.org | python3 -
poetry config virtualenvs.in-project true
poetry install --no-interaction
- &check_code_formatting
name: Check code formatting
script: |
set -e
poetry run black --check .
poetry run ruff check .
- &static_type_checks
name: Static type checks with mypy
script: poetry run mypy .
- &run_tests
name: Run tests
script: poetry run pytest --junitxml="test-report.xml"
test_report: test-report.xml
- &update_version_in_source
name: Update version number in source code
script: |
set -e
VERSION=$(poetry version --short)
echo "Using version $VERSION"
sed -i -e \
"s/__version__ = .*/__version__ = '${VERSION}'/g" \
src/codemagic/__version__.py
- &build_wheels
name: Build wheels
script: poetry build
workflows:
tests:
instance_type: mac_mini_m1
triggering:
events:
- push
cancel_previous_builds: true
cache: *cache
scripts:
- *install_dependencies
- *check_code_formatting
- *static_type_checks
- *run_tests
release-test:
name: Release [Test]
instance_type: mac_mini_m1
cache: *cache
environment:
groups:
- github
- pypi-test
scripts:
- *install_dependencies
- *check_code_formatting
- *static_type_checks
- *run_tests
- name: Bump version number for development build
script: poetry version "$(poetry version --short).${BUILD_NUMBER:?}"
- *update_version_in_source
- *build_wheels
- name: Make GitHub prerelease
script: |
set -e
TAG_NAME=v$(poetry version --short)
cp dist/codemagic_cli_tools-*-py3-none-any.whl dist/codemagic_cli_tools-latest-py3-none-any.whl
gh release create "${TAG_NAME}" \
--title "${TAG_NAME}" \
--notes "Test release of ${TAG_NAME}" \
--prerelease \
--draft \
dist/codemagic*.whl \
dist/codemagic*.tar.gz
rm dist/codemagic_cli_tools-latest-py3-none-any.whl
- name: Publish release to PyPI Test environment
script: |
rm dist/codemagic_cli_tools-*.tar.gz
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry publish \
--repository test-pypi \
--username "__token__" \
--password "${PYPI_TOKEN:?}"
artifacts: *artifacts
release:
name: Release
instance_type: mac_mini_m1
cache: *cache
environment:
groups:
- github
- pypi
scripts:
- name: Verify branch
script: |
if [ "${CM_BRANCH:?}" != "master" ];
then
echo "Not on master branch, cannot release from branch $CM_BRANCH"
exit 1
fi
- *install_dependencies
- *check_code_formatting
- *static_type_checks
- *run_tests
- *update_version_in_source
- *build_wheels
- name: Make GitHub release
script: |
set -e
TAG_NAME=v$(poetry version --short)
previous_version_line=$(grep -n "^Version " CHANGELOG.md | head -2 | tail -1 | cut -f1 -d:)
head -n "$(($previous_version_line - 1))" CHANGELOG.md | tail +3 > release_notes.md
cp dist/codemagic_cli_tools-*-py3-none-any.whl dist/codemagic_cli_tools-latest-py3-none-any.whl
gh release create "${TAG_NAME}" \
--title "${TAG_NAME}" \
--notes-file release_notes.md \
dist/codemagic*.whl \
dist/codemagic*.tar.gz
rm dist/codemagic_cli_tools-latest-py3-none-any.whl
- name: Publish release to PyPI
script: |
rm dist/codemagic_cli_tools-*.tar.gz
poetry publish --username "__token__" --password "${PYPI_TOKEN:?}"
artifacts: *artifacts