-
Notifications
You must be signed in to change notification settings - Fork 11
172 lines (147 loc) · 5.43 KB
/
run_release.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Run release
on:
# Push to master will publish a beta version.
push:
branches:
- master
tags-ignore:
- "**"
# A release via GitHub releases will publish a stable version.
release:
types: [published]
# Workflow dispatch will publish whatever you choose.
workflow_dispatch:
inputs:
release_type:
description: Release type
required: true
type: choice
default: alpha
options:
- alpha
- beta
- final
env:
PYTHON_VERSION: 3.12
jobs:
should_release:
name: Check whether to release
if: (!startsWith(github.event.head_commit.message, 'docs:') || github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
steps:
- name: Dummy step
run: "true"
lint_check:
name: Lint check
needs: [should_release]
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
type_check:
name: Type check
needs: [should_release]
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
unit_tests:
name: Unit tests
needs: [should_release]
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
# TODO: remove this once https://github.com/apify/apify-sdk-python/issues/241 is resolved
changelog_entry_check:
name: Changelog entry check
needs: [should_release]
uses: ./.github/workflows/_changelog_entry_check.yaml
# TODO: remove this once https://github.com/apify/apify-sdk-python/issues/241 is resolved
version_conflict_check:
name: Version conflict check
needs: [should_release]
uses: ./.github/workflows/_version_conflict_check.yaml
integration_tests:
name: Integration tests
needs: [should_release]
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
secrets: inherit
publish_to_pypi:
name: Publish to PyPI
needs:
[
should_release,
lint_check,
type_check,
unit_tests,
changelog_entry_check,
version_conflict_check,
integration_tests,
]
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
environment:
name: pypi
url: https://pypi.org/project/apify/
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Python dependencies
run: |
pipx install --python ${{ env.PYTHON_VERSION }} poetry
make install-dev
- # Determine if this is a prerelease or latest release
name: Determine release type
id: get-release-type
run: |
if [ ${{ github.event_name }} = release ]; then
release_type="final"
elif [ ${{ github.event_name }} = push ]; then
release_type="beta"
elif [ ${{ github.event_name }} = workflow_dispatch ]; then
release_type=${{ github.event.inputs.release_type }}
fi
if [ ${release_type} = final ]; then
docker_image_tag="latest"
elif [ ${release_type} = beta ]; then
docker_image_tag="beta"
else
docker_image_tag=""
fi
echo "release_type=${release_type}" >> $GITHUB_OUTPUT
echo "docker_image_tag=${docker_image_tag}" >> $GITHUB_OUTPUT
- # Check whether the released version is listed in CHANGELOG.md
name: Check whether the released version is listed in the changelog
if: steps.get-release-type.outputs.release_type != 'alpha'
run: make check-changelog-entry
- # Check version consistency and increment pre-release version number for prereleases (must be the last step before build)
name: Bump pre-release version
if: steps.get-release-type.outputs.release_type != 'final'
run: python ./scripts/update_version_for_prerelease.py ${{ steps.get-release-type.outputs.release_type }}
# Builds the package.
- name: Build package
run: make build
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- # Tag the current commit with the version tag if this is not made from the release event (releases are tagged with the release process)
name: Tag Version
if: github.event_name != 'release'
run: |
git_tag=v`python ./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
if: github.event_name == 'release'
run: gh release upload ${{ github.ref_name }} dist/*
env:
GH_TOKEN: ${{ github.token }}
- # Trigger building the Python Docker images in apify/apify-actor-docker repo
name: Trigger Docker image build
run: |
PACKAGE_VERSION=`python ./scripts/print_current_package_version.py`
gh api -X POST "/repos/apify/apify-actor-docker/dispatches" \
-F event_type=build-python-images \
-F client_payload[release_tag]=${{ steps.get-release-type.outputs.docker_image_tag }} \
-F client_payload[apify_version]=$PACKAGE_VERSION
env:
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}