-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathcodemagic.yaml
More file actions
119 lines (116 loc) · 3.55 KB
/
codemagic.yaml
File metadata and controls
119 lines (116 loc) · 3.55 KB
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
definitions:
artifacts: &artifacts
- dist/codemagic*.whl
- dist/codemagic*.tar.gz
scripts:
- &install_dependencies
name: Install dependencies
script: uv sync --frozen
- &check_code_formatting
name: Check code formatting
script: |
set -e
uv run ruff format --check .
uv run ruff check .
- &static_type_checks
name: Static type checks with mypy
script: uv run mypy .
- &run_tests
name: Run tests
script: uv 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=$(uv version --short)
echo "Using version $VERSION"
sed -i -e \
"s/__version__ = .*/__version__ = '${VERSION}'/g" \
src/codemagic/__version__.py
- &build_wheels
name: Build wheels
script: uv build
- &publish_to_pypi
name: Publish release to PyPI
script: |
rm dist/codemagic_cli_tools-*.tar.gz
uv publish --token "${PYPI_TOKEN:?}"
workflows:
tests:
triggering:
events:
- push
cancel_previous_builds: true
scripts:
- *install_dependencies
- *check_code_formatting
- *static_type_checks
- *run_tests
release-test:
name: Release [Test]
environment:
groups:
- github
- pypi-test
vars:
UV_PUBLISH_URL: https://test.pypi.org/legacy/
scripts:
- *install_dependencies
- *check_code_formatting
- *static_type_checks
- *run_tests
- name: Bump version number for development build
script: uv version "$(uv version --short).${BUILD_NUMBER:?}"
- *update_version_in_source
- *build_wheels
- name: Make GitHub prerelease
script: |
set -e
TAG_NAME=v$(uv 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
- *publish_to_pypi
artifacts: *artifacts
release:
name: Release
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$(uv 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
- *publish_to_pypi
artifacts: *artifacts