forked from apify/apify-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (120 loc) · 4.5 KB
/
release.yml
File metadata and controls
147 lines (120 loc) · 4.5 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
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
145
146
147
name: Check & Release
on:
# Push to master will publish a beta version
push:
branches:
- master
# A release via GitHub releases will publish a stable version
release:
types: [published]
jobs:
lint_and_test:
name: Lint and run unit tests
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Lint
run: ./lint_and_test.sh lint
- name: Type check
run: ./lint_and_test.sh types
- name: Unit tests
run: ./lint_and_test.sh tests
check_docs:
name: Check whether the documentation is up to date
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Check whether docs are built from the latest code
run: ./docs/res/check.sh
deploy:
name: Publish to PyPI
needs: [lint_and_test, check_docs]
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools twine wheel
- # Determine if this is a beta or latest release
name: Determine release type
run: echo "RELEASE_TYPE=$(if [ ${{ github.event_name }} = release ]; then echo latest; else echo beta; fi)" >> $GITHUB_ENV
- # Check whether the released version is listed in CHANGELOG.md
name: Check whether the released version is listed in the changelog
run: python ./.github/scripts/check_version_in_changelog.py
- # Check version consistency and increment pre-release version number for beta releases (must be the last step before build)
name: Bump pre-release version
if: env.RELEASE_TYPE == 'beta'
run: python ./.github/scripts/update_version_for_beta_release.py
- # Build a source distribution and a python3-only wheel
name: Build distribution files
run: python setup.py sdist bdist_wheel
- # Check whether the package description will render correctly on PyPI
name: Check package rendering on PyPI
run: python -m twine check dist/*
- # Publish package to PyPI using their official GitHub action
name: Publish package to PyPI
run: python -m twine upload --non-interactive --disable-progress-bar dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
- # Tag the current commit with the version tag if this is a beta release (stable releases are tagged with the release process)
name: Tag Version
if: env.RELEASE_TYPE == 'beta'
run: |
git_tag=v`python ./.github/scripts/print_current_package_version.py`
git tag $git_tag
git push origin $git_tag
- # Upload the build artifacts to the release
name: Upload the build artifacts to release
uses: svenstaro/upload-release-action@v2
if: env.RELEASE_TYPE == 'latest'
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*
file_glob: true
tag: ${{ github.ref }}
- # Get the current package version for use in Docker images
name: Parse package version for Docker images
id: get-package-version
run: |
package_version=`python ./.github/scripts/print_current_package_version.py`
echo "::set-output name=package_version::$package_version"
- # Trigger building the docker images in apify/apify-actor-docker repo
name: Trigger Docker Image Build
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.TRIGGER_DOCKER_IMAGE_BUILD_TOKEN }}
repository: apify/apify-actor-docker
event-type: build-python-images
client-payload: >
{
"release_tag": "${{ env.RELEASE_TYPE }}",
"apify_client_version": "${{ steps.get-package-version.outputs.package_version }}"
}