Skip to content

Commit 65f2500

Browse files
janbucharvdusek
andauthored
ci: Automate the release process (#302)
- closes #241 --------- Co-authored-by: Vlada Dusek <v.dusek96@gmail.com>
1 parent 80a2a7f commit 65f2500

14 files changed

+350
-524
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: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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+
existing_changelog_path: CHANGELOG.md
21+
steps:
22+
- uses: apify/workflows/git-cliff-release@main
23+
id: release_metadata
24+
name: Prepare release metadata
25+
with:
26+
release_type: prerelease
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+
integration_tests:
41+
name: Integration tests
42+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
43+
secrets: inherit
44+
45+
update_changelog:
46+
name: Update changelog
47+
needs: [release_metadata, lint_check, type_check, unit_tests, integration_tests]
48+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
49+
with:
50+
version_number: ${{ needs.release_metadata.outputs.version_number }}
51+
changelog: ${{ needs.release_metadata.outputs.changelog }}
52+
secrets:
53+
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
54+
55+
publish_to_pypi:
56+
name: Publish to PyPI
57+
needs: [release_metadata, update_changelog]
58+
runs-on: ubuntu-latest
59+
permissions:
60+
contents: write
61+
id-token: write # Required for OIDC authentication.
62+
environment:
63+
name: pypi
64+
url: https://pypi.org/project/apify
65+
steps:
66+
- name: Prepare distribution
67+
uses: apify/workflows/prepare-pypi-distribution@main
68+
with:
69+
package_name: apify
70+
is_prerelease: "yes"
71+
version_number: ${{ needs.release_metadata.outputs.version_number }}
72+
ref: ${{ needs.update_changelog.changelog_commitish }}
73+
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
74+
- name: Publish package to PyPI
75+
uses: pypa/gh-action-pypi-publish@release/v1
76+
77+
trigger_docker_build:
78+
name: Trigger Docker image build
79+
needs: [release_metadata, update_changelog]
80+
runs-on: ubuntu-latest
81+
steps:
82+
- # Trigger building the Python Docker images in apify/apify-actor-docker repo
83+
name: Trigger Docker image build
84+
run: |
85+
gh api -X POST "/repos/apify/apify-actor-docker/dispatches" \
86+
-F event_type=build-python-images \
87+
-F client_payload[release_tag]=beta \
88+
-F client_payload[apify_version]=${{ needs.release_metadata.outputs.version_number }}
89+
env:
90+
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}

.github/workflows/release.yaml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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:
29+
version_number: ${{ steps.release_metadata.outputs.version_number }}
30+
tag_name: ${{ steps.release_metadata.outputs.tag_name }}
31+
changelog: ${{ steps.release_metadata.outputs.changelog }}
32+
release_notes: ${{ steps.release_metadata.outputs.release_notes }}
33+
steps:
34+
- uses: apify/workflows/git-cliff-release@main
35+
name: Prepare release metadata
36+
id: release_metadata
37+
with:
38+
release_type: ${{ inputs.release_type }}
39+
custom_version: ${{ inputs.custom_version }}
40+
existing_changelog_path: CHANGELOG.md
41+
42+
lint_check:
43+
name: Lint check
44+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
45+
46+
type_check:
47+
name: Type check
48+
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
49+
50+
unit_tests:
51+
name: Unit tests
52+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
53+
54+
integration_tests:
55+
name: Integration tests
56+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
57+
secrets: inherit
58+
59+
update_changelog:
60+
name: Update changelog
61+
needs: [release_metadata, lint_check, type_check, unit_tests, integration_tests]
62+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
63+
with:
64+
version_number: ${{ needs.release_metadata.outputs.version_number }}
65+
changelog: ${{ needs.release_metadata.outputs.changelog }}
66+
secrets:
67+
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
68+
69+
create_github_release:
70+
name: Create github release
71+
needs: [release_metadata, update_changelog]
72+
runs-on: ubuntu-latest
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
steps:
76+
- name: Create release
77+
uses: softprops/action-gh-release@v2
78+
with:
79+
tag_name: ${{ needs.release_metadata.outputs.tag_name }}
80+
name: ${{ needs.release_metadata.outputs.version_number }}
81+
target_commitish: ${{ needs.update_changelog.outputs.changelog_commitish }}
82+
body: ${{ needs.release_metadata.outputs.release_notes }}
83+
84+
publish_to_pypi:
85+
name: Publish to PyPI
86+
needs: [release_metadata, update_changelog]
87+
runs-on: ubuntu-latest
88+
permissions:
89+
contents: write
90+
id-token: write # Required for OIDC authentication.
91+
environment:
92+
name: pypi
93+
url: https://pypi.org/project/apify
94+
steps:
95+
- name: Prepare distribution
96+
uses: apify/workflows/prepare-pypi-distribution@main
97+
with:
98+
package_name: apify
99+
is_prerelease: ""
100+
version_number: ${{ needs.release_metadata.outputs.version_number }}
101+
ref: ${{ needs.update_changelog.outputs.changelog_commitish }}
102+
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
103+
- name: Publish package to PyPI
104+
uses: pypa/gh-action-pypi-publish@release/v1
105+
106+
trigger_docker_build:
107+
name: Trigger Docker image build
108+
needs: [release_metadata, update_changelog]
109+
runs-on: ubuntu-latest
110+
steps:
111+
- # Trigger building the Python Docker images in apify/apify-actor-docker repo
112+
name: Trigger Docker image build
113+
run: |
114+
gh api -X POST "/repos/apify/apify-actor-docker/dispatches" \
115+
-F event_type=build-python-images \
116+
-F client_payload[release_tag]=latest \
117+
-F client_payload[apify_version]=${{ needs.release_metadata.outputs.version_number }}
118+
env:
119+
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}

.github/workflows/run_code_checks.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ jobs:
1919
name: Unit tests
2020
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
2121

22-
# TODO: remove this once https://github.com/apify/apify-sdk-python/issues/241 is resolved
23-
changelog_entry_check:
24-
name: Changelog entry check
25-
uses: ./.github/workflows/_changelog_entry_check.yaml
26-
27-
# TODO: remove this once https://github.com/apify/apify-sdk-python/issues/241 is resolved
28-
version_conflict_check:
29-
name: Version conflict check
30-
uses: ./.github/workflows/_version_conflict_check.yaml
31-
3222
docs_check:
3323
name: Docs check
3424
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main

0 commit comments

Comments
 (0)