Skip to content

Commit 05cf887

Browse files
janbucharvdusek
andauthored
ci: Automate the release process (#278)
- closes #273 --------- Co-authored-by: Vlada Dusek <[email protected]>
1 parent 7aed9c9 commit 05cf887

15 files changed

+322
-445
lines changed

.github/workflows/_changelog_entry_check.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/_version_conflict_check.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/pre_release.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Create a pre-release
2+
3+
on:
4+
# Trigger a beta version release (pre-release) on push to the master branch.
5+
push:
6+
branches:
7+
- master
8+
tags-ignore:
9+
- "**" # Ignore all tags to prevent duplicate builds when tags are pushed.
10+
11+
jobs:
12+
release_metadata:
13+
if: "!startsWith(github.event.head_commit.message, 'docs') && !startsWith(github.event.head_commit.message, 'ci') && startsWith(github.repository, 'apify/')"
14+
name: Prepare release metadata
15+
runs-on: ubuntu-latest
16+
outputs:
17+
version_number: ${{ steps.release_metadata.outputs.version_number }}
18+
tag_name: ${{ steps.release_metadata.outputs.tag_name }}
19+
changelog: ${{ steps.release_metadata.outputs.changelog }}
20+
steps:
21+
- uses: apify/workflows/git-cliff-release@main
22+
id: release_metadata
23+
name: Prepare release metadata
24+
with:
25+
release_type: prerelease
26+
existing_changelog_path: CHANGELOG.md
27+
28+
lint_check:
29+
name: Lint check
30+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
31+
32+
type_check:
33+
name: Type check
34+
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
35+
36+
unit_tests:
37+
name: Unit tests
38+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
39+
40+
async_docstrings:
41+
name: Async dostrings check
42+
uses: ./.github/workflows/_async_docstrings_check.yaml
43+
44+
integration_tests:
45+
name: Integration tests
46+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
47+
secrets: inherit
48+
49+
update_changelog:
50+
name: Update changelog
51+
needs: [release_metadata, lint_check, type_check, unit_tests, integration_tests]
52+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
53+
with:
54+
version_number: ${{ needs.release_metadata.outputs.version_number }}
55+
changelog: ${{ needs.release_metadata.outputs.changelog }}
56+
secrets:
57+
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
58+
59+
publish_to_pypi:
60+
name: Publish to PyPI
61+
needs: [release_metadata, update_changelog]
62+
runs-on: ubuntu-latest
63+
permissions:
64+
contents: write
65+
id-token: write # Required for OIDC authentication.
66+
environment:
67+
name: pypi
68+
url: https://pypi.org/project/apify-client
69+
steps:
70+
- name: Prepare distribution
71+
uses: apify/workflows/prepare-pypi-distribution@main
72+
with:
73+
package_name: apify-client
74+
is_prerelease: "yes"
75+
version_number: ${{ needs.release_metadata.outputs.version_number }}
76+
ref: ${{ needs.update_changelog.changelog_commitish }}
77+
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
78+
- name: Publish package to PyPI
79+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/release.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Create a release
2+
3+
on:
4+
# Trigger a stable version release via GitHub's UI, with the ability to specify the type of release.
5+
workflow_dispatch:
6+
inputs:
7+
release_type:
8+
description: Release type
9+
required: true
10+
type: choice
11+
default: auto
12+
options:
13+
- auto
14+
- custom
15+
- patch
16+
- minor
17+
- major
18+
custom_version:
19+
description: The custom version to bump to (only for "custom" type)
20+
required: false
21+
type: string
22+
default: ""
23+
24+
jobs:
25+
release_metadata:
26+
name: Prepare release metadata
27+
runs-on: ubuntu-latest
28+
outputs:etadata, lint_check, type_check, unit_tests]
29+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
30+
with:
31+
version_number: ${{ needs.release_metadata.outputs.version_number }}
32+
changelog: ${{ needs.release_metadata.outputs.changelog }}
33+
secrets:
34+
version_number: ${{ steps.release_metadata.outputs.version_number }}
35+
tag_name: ${{ steps.release_metadata.outputs.tag_name }}
36+
changelog: ${{ steps.release_metadata.outputs.changelog }}
37+
release_notes: ${{ steps.release_metadata.outputs.release_notes }}
38+
steps:
39+
- uses: apify/workflows/git-cliff-release@main
40+
name: Prepare release metadata
41+
id: release_metadata
42+
with:
43+
release_type: ${{ inputs.release_type }}
44+
custom_version: ${{ inputs.custom_version }}
45+
existing_changelog_path: CHANGELOG.md
46+
47+
lint_check:
48+
name: Lint check
49+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
50+
51+
type_check:
52+
name: Type check
53+
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
54+
55+
unit_tests:
56+
name: Unit tests
57+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
58+
59+
async_docstrings:
60+
name: Async dostrings check
61+
uses: ./.github/workflows/_async_docstrings_check.yaml
62+
63+
integration_tests:
64+
name: Integration tests
65+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
66+
secrets: inherit
67+
68+
update_changelog:
69+
name: Update changelog
70+
needs: [release_metadata, lint_check, type_check, unit_tests, integration_tests]
71+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
72+
with:
73+
version_number: ${{ needs.release_metadata.outputs.version_number }}
74+
changelog: ${{ needs.release_metadata.outputs.changelog }}
75+
secrets:
76+
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
77+
78+
create_github_release:
79+
name: Create github release
80+
needs: [release_metadata, update_changelog]
81+
runs-on: ubuntu-latest
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84+
steps:
85+
- name: Create release
86+
uses: softprops/action-gh-release@v2
87+
with:
88+
tag_name: ${{ needs.release_metadata.outputs.tag_name }}
89+
name: ${{ needs.release_metadata.outputs.version_number }}
90+
target_commitish: ${{ needs.update_changelog.outputs.changelog_commitish }}
91+
body: ${{ needs.release_metadata.outputs.release_notes }}
92+
93+
publish_to_pypi:
94+
name: Publish to PyPI
95+
needs: [release_metadata, update_changelog]
96+
runs-on: ubuntu-latest
97+
permissions:
98+
contents: write
99+
id-token: write # Required for OIDC authentication.
100+
environment:
101+
name: pypi
102+
url: https://pypi.org/project/apify-client
103+
steps:
104+
- name: Prepare distribution
105+
uses: apify/workflows/prepare-pypi-distribution@main
106+
with:
107+
package_name: apify-client
108+
is_prerelease: ""
109+
version_number: ${{ needs.release_metadata.outputs.version_number }}
110+
ref: ${{ needs.update_changelog.changelog_commitish }}
111+
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
112+
- name: Publish package to PyPI
113+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/run_code_checks.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ jobs:
2323
name: Async dostrings check
2424
uses: ./.github/workflows/_async_docstrings_check.yaml
2525

26-
# TODO: remove this once https://github.com/apify/apify-sdk-python/issues/241 is resolved
27-
changelog_entry_check:
28-
name: Changelog entry check
29-
uses: ./.github/workflows/_changelog_entry_check.yaml
30-
31-
# TODO: remove this once https://github.com/apify/apify-sdk-python/issues/241 is resolved
32-
version_conflict_check:
33-
name: Version conflict check
34-
uses: ./.github/workflows/_version_conflict_check.yaml
35-
3626
docs_check:
3727
name: Docs check
3828
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main

0 commit comments

Comments
 (0)