Skip to content

Commit 649b031

Browse files
authored
chore(ci): Align GitHub workflows across Python projects (#712)
1 parent 13e8877 commit 649b031

File tree

11 files changed

+249
-198
lines changed

11 files changed

+249
-198
lines changed

.github/workflows/_check_code.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Code checks
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI.
5+
workflow_dispatch:
6+
7+
# Runs when invoked by another workflow.
8+
workflow_call:
9+
10+
jobs:
11+
actions_lint_check:
12+
name: Actions lint check
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v6
17+
- name: Run actionlint
18+
uses: rhysd/actionlint@v1.7.9
19+
20+
lint_check:
21+
name: Lint check
22+
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
23+
with:
24+
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
25+
26+
type_check:
27+
name: Type check
28+
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
29+
with:
30+
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'

.github/workflows/_check_docs.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Doc checks
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI.
5+
workflow_dispatch:
6+
7+
# Runs when invoked by another workflow.
8+
workflow_call:
9+
10+
jobs:
11+
doc_checks:
12+
name: Doc checks
13+
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main

.github/workflows/build_and_deploy_docs.yaml renamed to .github/workflows/_release_docs.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
name: Build and deploy docs
1+
name: Doc release
22

33
on:
4-
push:
5-
branches:
6-
- master
4+
# Runs when manually triggered from the GitHub UI.
75
workflow_dispatch:
86

7+
# Runs when invoked by another workflow.
8+
workflow_call:
9+
inputs:
10+
ref:
11+
required: true
12+
type: string
13+
914
env:
1015
NODE_VERSION: 22
1116
PYTHON_VERSION: 3.14
17+
CHECKOUT_REF: ${{ github.event_name == 'workflow_call' && inputs.ref || github.ref }}
1218

1319
jobs:
14-
build_and_deploy_docs:
20+
release_docs:
21+
name: Doc release
1522
environment:
1623
name: github-pages
1724
permissions:
@@ -25,6 +32,7 @@ jobs:
2532
uses: actions/checkout@v6
2633
with:
2734
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
35+
ref: ${{ env.CHECKOUT_REF }}
2836

2937
- name: Set up Node
3038
uses: actions/setup-node@v6

.github/workflows/_tests.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Tests
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI.
5+
workflow_dispatch:
6+
7+
# Runs when invoked by another workflow.
8+
workflow_call:
9+
10+
jobs:
11+
unit_tests:
12+
name: Unit tests
13+
uses: apify/workflows/.github/workflows/python_unit_tests.yaml@main
14+
secrets: inherit
15+
with:
16+
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
17+
operating-systems: '["ubuntu-latest", "windows-latest"]'
18+
python-version-for-codecov: "3.14"
19+
operating-system-for-codecov: ubuntu-latest
20+
21+
integration_tests:
22+
name: Integration tests
23+
uses: apify/workflows/.github/workflows/python_integration_tests.yaml@main
24+
secrets: inherit
25+
with:
26+
python-versions: '["3.10", "3.14"]'
27+
operating-systems: '["ubuntu-latest"]'
28+
python-version-for-codecov: "3.14"
29+
operating-system-for-codecov: ubuntu-latest

.github/workflows/check_pr_title.yaml

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
name: Create a release
1+
name: Stable release
22

33
on:
4-
# Trigger a stable version release via GitHub's UI, with the ability to specify the type of release.
4+
# Runs when manually triggered from the GitHub UI, with options to specify the type of release.
55
workflow_dispatch:
66
inputs:
77
release_type:
@@ -26,63 +26,55 @@ concurrency:
2626
cancel-in-progress: false
2727

2828
jobs:
29-
release_metadata:
30-
name: Prepare release metadata
29+
code_checks:
30+
name: Code checks
31+
uses: ./.github/workflows/_check_code.yaml
32+
33+
release_prepare:
34+
name: Release prepare
35+
needs: [code_checks]
3136
runs-on: ubuntu-latest
3237
outputs:
33-
version_number: ${{ steps.release_metadata.outputs.version_number }}
34-
tag_name: ${{ steps.release_metadata.outputs.tag_name }}
35-
changelog: ${{ steps.release_metadata.outputs.changelog }}
36-
release_notes: ${{ steps.release_metadata.outputs.release_notes }}
38+
version_number: ${{ steps.release_prepare.outputs.version_number }}
39+
tag_name: ${{ steps.release_prepare.outputs.tag_name }}
40+
changelog: ${{ steps.release_prepare.outputs.changelog }}
41+
release_notes: ${{ steps.release_prepare.outputs.release_notes }}
3742
steps:
3843
- uses: apify/workflows/git-cliff-release@main
39-
name: Prepare release metadata
40-
id: release_metadata
44+
name: Release prepare
45+
id: release_prepare
4146
with:
4247
release_type: ${{ inputs.release_type }}
4348
custom_version: ${{ inputs.custom_version }}
4449
existing_changelog_path: CHANGELOG.md
4550

46-
lint_check:
47-
name: Lint check
48-
uses: apify/workflows/.github/workflows/python_lint_check.yaml@main
49-
with:
50-
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
51-
52-
type_check:
53-
name: Type check
54-
uses: apify/workflows/.github/workflows/python_type_check.yaml@main
55-
with:
56-
python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]'
57-
58-
update_changelog:
59-
name: Update changelog
60-
needs: [release_metadata, lint_check, type_check]
51+
changelog_update:
52+
name: Changelog update
53+
needs: [release_prepare]
6154
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
6255
with:
63-
version_number: ${{ needs.release_metadata.outputs.version_number }}
64-
changelog: ${{ needs.release_metadata.outputs.changelog }}
65-
secrets:
66-
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
56+
version_number: ${{ needs.release_prepare.outputs.version_number }}
57+
changelog: ${{ needs.release_prepare.outputs.changelog }}
58+
secrets: inherit
6759

68-
create_github_release:
69-
name: Create github release
70-
needs: [release_metadata, update_changelog]
60+
github_release:
61+
name: GitHub release
62+
needs: [release_prepare, changelog_update]
7163
runs-on: ubuntu-latest
7264
env:
7365
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7466
steps:
75-
- name: Create release
67+
- name: GitHub release
7668
uses: softprops/action-gh-release@v2
7769
with:
78-
tag_name: ${{ needs.release_metadata.outputs.tag_name }}
79-
name: ${{ needs.release_metadata.outputs.version_number }}
80-
target_commitish: ${{ needs.update_changelog.outputs.changelog_commitish }}
81-
body: ${{ needs.release_metadata.outputs.release_notes }}
70+
tag_name: ${{ needs.release_prepare.outputs.tag_name }}
71+
name: ${{ needs.release_prepare.outputs.version_number }}
72+
target_commitish: ${{ needs.changelog_update.outputs.changelog_commitish }}
73+
body: ${{ needs.release_prepare.outputs.release_notes }}
8274

83-
publish_to_pypi:
84-
name: Publish to PyPI
85-
needs: [release_metadata, update_changelog]
75+
pypi_publish:
76+
name: PyPI publish
77+
needs: [release_prepare, changelog_update]
8678
runs-on: ubuntu-latest
8779
permissions:
8880
contents: write
@@ -96,15 +88,16 @@ jobs:
9688
with:
9789
package_name: apify
9890
is_prerelease: ""
99-
version_number: ${{ needs.release_metadata.outputs.version_number }}
100-
ref: ${{ needs.update_changelog.outputs.changelog_commitish }}
91+
version_number: ${{ needs.release_prepare.outputs.version_number }}
92+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
93+
10194
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
10295
- name: Publish package to PyPI
10396
uses: pypa/gh-action-pypi-publish@release/v1
10497

10598
trigger_docker_build:
10699
name: Trigger Docker image build
107-
needs: [release_metadata, update_changelog]
100+
needs: [release_prepare, changelog_update]
108101
runs-on: ubuntu-latest
109102
steps:
110103
# Trigger building the Python Docker images in apify/apify-actor-docker repo
@@ -113,6 +106,6 @@ jobs:
113106
gh api -X POST "/repos/apify/apify-actor-docker/dispatches" \
114107
-F event_type=build-python-images \
115108
-F 'client_payload[release_tag]=latest' \
116-
-F 'client_payload[apify_version]=${{ needs.release_metadata.outputs.version_number }}'
109+
-F 'client_payload[apify_version]=${{ needs.release_prepare.outputs.version_number }}'
117110
env:
118111
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
name: Update new issue
1+
name: CI (issue)
22

33
on:
4+
# Runs when a new issue is opened.
45
issues:
56
types:
67
- opened
78

89
jobs:
910
label_issues:
10-
name: Label issues
11+
name: Add labels
1112
runs-on: ubuntu-latest
1213
permissions:
1314
issues: write

.github/workflows/on_master.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: CI (master)
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags-ignore:
8+
- "**" # Ignore all tags to avoid duplicate executions triggered by tag pushes.
9+
10+
concurrency:
11+
group: release
12+
cancel-in-progress: false
13+
14+
jobs:
15+
doc_checks:
16+
name: Doc checks
17+
uses: ./.github/workflows/_check_docs.yaml
18+
19+
doc_release:
20+
# Skip this for non-docs commits and forks.
21+
if: "startsWith(github.event.head_commit.message, 'docs') && startsWith(github.repository, 'apify/')"
22+
name: Doc release
23+
needs: [doc_checks]
24+
uses: ./.github/workflows/_release_docs.yaml
25+
with:
26+
# Use the same ref as the one that triggered the workflow.
27+
ref: ${{ github.ref }}
28+
secrets: inherit
29+
30+
code_checks:
31+
name: Code checks
32+
uses: ./.github/workflows/_check_code.yaml
33+
34+
tests:
35+
# Skip this for "ci" and "docs" commits.
36+
if: "!startsWith(github.event.head_commit.message, 'ci') && !startsWith(github.event.head_commit.message, 'docs')"
37+
name: Tests
38+
uses: ./.github/workflows/_tests.yaml
39+
secrets: inherit
40+
41+
release_prepare:
42+
# Skip this for "ci", "docs" and "test" commits and for forks.
43+
if: "!startsWith(github.event.head_commit.message, 'ci') && !startsWith(github.event.head_commit.message, 'docs') && !startsWith(github.event.head_commit.message, 'test') && startsWith(github.repository, 'apify/')"
44+
name: Release prepare
45+
needs: [code_checks, tests]
46+
runs-on: ubuntu-latest
47+
outputs:
48+
version_number: ${{ steps.release_prepare.outputs.version_number }}
49+
tag_name: ${{ steps.release_prepare.outputs.tag_name }}
50+
changelog: ${{ steps.release_prepare.outputs.changelog }}
51+
steps:
52+
- uses: apify/workflows/git-cliff-release@main
53+
id: release_prepare
54+
name: Release prepare
55+
with:
56+
release_type: prerelease
57+
existing_changelog_path: CHANGELOG.md
58+
59+
changelog_update:
60+
name: Changelog update
61+
needs: [release_prepare]
62+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
63+
with:
64+
version_number: ${{ needs.release_prepare.outputs.version_number }}
65+
changelog: ${{ needs.release_prepare.outputs.changelog }}
66+
secrets: inherit
67+
68+
pypi_publish:
69+
name: PyPI publish
70+
needs: [release_prepare, changelog_update]
71+
runs-on: ubuntu-latest
72+
permissions:
73+
contents: write
74+
id-token: write # Required for OIDC authentication.
75+
environment:
76+
name: pypi
77+
url: https://pypi.org/project/apify
78+
steps:
79+
- name: Prepare distribution
80+
uses: apify/workflows/prepare-pypi-distribution@main
81+
with:
82+
package_name: apify
83+
is_prerelease: "yes"
84+
version_number: ${{ needs.release_prepare.outputs.version_number }}
85+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
86+
87+
- name: Publish package to PyPI
88+
uses: pypa/gh-action-pypi-publish@release/v1
89+
90+
doc_release_post_publish:
91+
name: Doc release post publish
92+
needs: [changelog_update, pypi_publish]
93+
uses: ./.github/workflows/_release_docs.yaml
94+
with:
95+
# Use the ref from the changelog update to include the updated changelog.
96+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
97+
secrets: inherit

0 commit comments

Comments
 (0)