Skip to content

Commit 0fa43bc

Browse files
authored
chore(ci): Align GitHub workflows across Python projects (#559)
1 parent b6f7b00 commit 0fa43bc

14 files changed

+329
-308
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/_async_docstrings_check.yaml renamed to .github/workflows/_check_docstrings.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
name: Async docstrings check
1+
name: Docstrings checks
22

33
on:
4+
# Runs when manually triggered from the GitHub UI.
5+
workflow_dispatch:
6+
7+
# Runs when invoked by another workflow.
48
workflow_call:
59

610
env:
711
PYTHON_VERSION: 3.14
812

913
jobs:
10-
async_docstring_check:
11-
name: Async docstrings check
14+
docstrings_checks:
15+
name: Docstrings checks
1216
runs-on: ubuntu-latest
1317

1418
steps:
@@ -28,5 +32,5 @@ jobs:
2832
- name: Install dependencies
2933
run: make install-dev
3034

31-
- name: Run async docstrings check
35+
- name: Async docstrings check
3236
run: make check-async-docstrings

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

Lines changed: 16 additions & 6 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:
10-
NODE_VERSION: 20
15+
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
@@ -67,6 +75,8 @@ jobs:
6775

6876
- name: Build Docusaurus docs
6977
run: make build-docs
78+
env:
79+
APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }}
7080

7181
- name: Set up GitHub Pages
7282
uses: actions/configure-pages@v5

.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: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Stable release
2+
3+
on:
4+
# Runs when manually triggered from the GitHub UI, with options 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+
concurrency:
25+
group: release
26+
cancel-in-progress: false
27+
28+
jobs:
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]
36+
runs-on: ubuntu-latest
37+
outputs:
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 }}
42+
steps:
43+
- uses: apify/workflows/git-cliff-release@main
44+
name: Release prepare
45+
id: release_prepare
46+
with:
47+
release_type: ${{ inputs.release_type }}
48+
custom_version: ${{ inputs.custom_version }}
49+
existing_changelog_path: CHANGELOG.md
50+
51+
changelog_update:
52+
name: Changelog update
53+
needs: [release_prepare]
54+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
55+
with:
56+
version_number: ${{ needs.release_prepare.outputs.version_number }}
57+
changelog: ${{ needs.release_prepare.outputs.changelog }}
58+
secrets: inherit
59+
60+
github_release:
61+
name: GitHub release
62+
needs: [release_prepare, changelog_update]
63+
runs-on: ubuntu-latest
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
steps:
67+
- name: GitHub release
68+
uses: softprops/action-gh-release@v2
69+
with:
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 }}
74+
75+
pypi_publish:
76+
name: PyPI publish
77+
needs: [release_prepare, changelog_update]
78+
runs-on: ubuntu-latest
79+
permissions:
80+
contents: write
81+
id-token: write # Required for OIDC authentication.
82+
environment:
83+
name: pypi
84+
url: https://pypi.org/project/apify-client
85+
steps:
86+
- name: Prepare distribution
87+
uses: apify/workflows/prepare-pypi-distribution@main
88+
with:
89+
package_name: apify-client
90+
is_prerelease: ""
91+
version_number: ${{ needs.release_prepare.outputs.version_number }}
92+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
93+
94+
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
95+
- name: Publish package to PyPI
96+
uses: pypa/gh-action-pypi-publish@release/v1
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: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
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+
docstrings_checks:
35+
name: Docstrings checks
36+
uses: ./.github/workflows/_check_docstrings.yaml
37+
38+
tests:
39+
# Skip this for "ci" and "docs" commits.
40+
if: "!startsWith(github.event.head_commit.message, 'ci') && !startsWith(github.event.head_commit.message, 'docs')"
41+
name: Tests
42+
uses: ./.github/workflows/_tests.yaml
43+
secrets: inherit
44+
45+
release_prepare:
46+
# Skip this for "ci", "docs" and "test" commits and for forks.
47+
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/')"
48+
name: Release prepare
49+
needs: [code_checks, docstrings_checks, tests]
50+
runs-on: ubuntu-latest
51+
outputs:
52+
version_number: ${{ steps.release_prepare.outputs.version_number }}
53+
tag_name: ${{ steps.release_prepare.outputs.tag_name }}
54+
changelog: ${{ steps.release_prepare.outputs.changelog }}
55+
steps:
56+
- uses: apify/workflows/git-cliff-release@main
57+
id: release_prepare
58+
name: Release prepare
59+
with:
60+
release_type: prerelease
61+
existing_changelog_path: CHANGELOG.md
62+
63+
changelog_update:
64+
name: Changelog update
65+
needs: [release_prepare]
66+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
67+
with:
68+
version_number: ${{ needs.release_prepare.outputs.version_number }}
69+
changelog: ${{ needs.release_prepare.outputs.changelog }}
70+
secrets: inherit
71+
72+
pypi_publish:
73+
name: PyPI publish
74+
needs: [release_prepare, changelog_update]
75+
runs-on: ubuntu-latest
76+
permissions:
77+
contents: write
78+
id-token: write # Required for OIDC authentication.
79+
environment:
80+
name: pypi
81+
url: https://pypi.org/project/apify-client
82+
steps:
83+
- name: Prepare distribution
84+
uses: apify/workflows/prepare-pypi-distribution@main
85+
with:
86+
package_name: apify-client
87+
is_prerelease: "yes"
88+
version_number: ${{ needs.release_prepare.outputs.version_number }}
89+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
90+
91+
- name: Publish package to PyPI
92+
uses: pypa/gh-action-pypi-publish@release/v1
93+
94+
doc_release_post_publish:
95+
name: Doc release post publish
96+
needs: [changelog_update, pypi_publish]
97+
uses: ./.github/workflows/_release_docs.yaml
98+
with:
99+
# Use the ref from the changelog update to include the updated changelog.
100+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
101+
secrets: inherit

0 commit comments

Comments
 (0)