Skip to content

Commit 77edd53

Browse files
committed
ci: Refactor release workflows and secrets handling
1 parent bf4a196 commit 77edd53

File tree

8 files changed

+139
-115
lines changed

8 files changed

+139
-115
lines changed

.github/workflows/_check_docs.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ on:
66

77
# Runs when invoked by another workflow.
88
workflow_call:
9+
secrets:
10+
APIFY_SIGNING_TOKEN:
11+
required: false
912

1013
jobs:
1114
doc_checks:
1215
name: Doc checks
1316
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main
14-
secrets: inherit
17+
secrets:
18+
APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }}

.github/workflows/_release_docs.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@ on:
1010
ref:
1111
required: true
1212
type: string
13+
secrets:
14+
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN:
15+
required: true
16+
APIFY_SIGNING_TOKEN:
17+
required: true
18+
SEGMENT_TOKEN:
19+
required: false
1320

1421
env:
1522
NODE_VERSION: 22
1623
PYTHON_VERSION: 3.14
24+
CHECKOUT_REF: ${{ github.event_name == 'workflow_call' && inputs.ref || github.ref }}
1725

1826
jobs:
1927
release_docs:
@@ -31,7 +39,7 @@ jobs:
3139
uses: actions/checkout@v6
3240
with:
3341
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
34-
ref: ${{ github.event_name == 'workflow_call' && inputs.ref || github.ref }}
42+
ref: ${{ env.CHECKOUT_REF }}
3543

3644
- name: Set up Node
3745
uses: actions/setup-node@v6

.github/workflows/_release_pre.yaml

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

.github/workflows/_tests.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66

77
# Runs when invoked by another workflow.
88
workflow_call:
9+
secrets:
10+
APIFY_HTTPBIN_TOKEN:
11+
required: false
12+
CODECOV_TOKEN:
13+
required: false
914

1015
jobs:
1116
unit_tests:

.github/workflows/manual_release_stable.yaml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,52 @@ jobs:
3030
name: Code checks
3131
uses: ./.github/workflows/_check_code.yaml
3232

33-
release_metadata:
34-
name: Prepare release metadata
33+
release_prepare:
34+
name: Release prepare
3535
needs: [code_checks]
3636
runs-on: ubuntu-latest
3737
outputs:
38-
version_number: ${{ steps.release_metadata.outputs.version_number }}
39-
tag_name: ${{ steps.release_metadata.outputs.tag_name }}
40-
changelog: ${{ steps.release_metadata.outputs.changelog }}
41-
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 }}
4242
steps:
4343
- uses: apify/workflows/git-cliff-release@main
44-
name: Prepare release metadata
45-
id: release_metadata
44+
name: Release prepare
45+
id: release_prepare
4646
with:
4747
release_type: ${{ inputs.release_type }}
4848
custom_version: ${{ inputs.custom_version }}
4949
existing_changelog_path: CHANGELOG.md
5050

51-
update_changelog:
52-
name: Update changelog
53-
needs: [release_metadata]
51+
changelog_update:
52+
name: Changelog update
53+
needs: [release_prepare]
5454
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
5555
with:
56-
version_number: ${{ needs.release_metadata.outputs.version_number }}
57-
changelog: ${{ needs.release_metadata.outputs.changelog }}
56+
version_number: ${{ needs.release_prepare.outputs.version_number }}
57+
changelog: ${{ needs.release_prepare.outputs.changelog }}
5858
secrets:
5959
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
6060

61-
create_github_release:
62-
name: Create GitHub release
63-
needs: [release_metadata, update_changelog]
61+
github_release:
62+
name: GitHub release
63+
needs: [release_prepare, changelog_update]
6464
runs-on: ubuntu-latest
6565
env:
6666
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6767
steps:
68-
- name: Create release
68+
- name: GitHub release
6969
uses: softprops/action-gh-release@v2
7070
with:
71-
tag_name: ${{ needs.release_metadata.outputs.tag_name }}
72-
name: ${{ needs.release_metadata.outputs.version_number }}
73-
target_commitish: ${{ needs.update_changelog.outputs.changelog_commitish }}
74-
body: ${{ needs.release_metadata.outputs.release_notes }}
71+
tag_name: ${{ needs.release_prepare.outputs.tag_name }}
72+
name: ${{ needs.release_prepare.outputs.version_number }}
73+
target_commitish: ${{ needs.changelog_update.outputs.changelog_commitish }}
74+
body: ${{ needs.release_prepare.outputs.release_notes }}
7575

76-
publish_to_pypi:
77-
name: Publish to PyPI
78-
needs: [release_metadata, update_changelog]
76+
pypi_publish:
77+
name: PyPI publish
78+
needs: [release_prepare, changelog_update]
7979
runs-on: ubuntu-latest
8080
permissions:
8181
contents: write
@@ -89,8 +89,8 @@ jobs:
8989
with:
9090
package_name: crawlee
9191
is_prerelease: ""
92-
version_number: ${{ needs.release_metadata.outputs.version_number }}
93-
ref: ${{ needs.update_changelog.outputs.changelog_commitish }}
92+
version_number: ${{ needs.release_prepare.outputs.version_number }}
93+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
9494
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
9595
- name: Publish package to PyPI
9696
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/on_master.yaml

Lines changed: 83 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,108 @@
11
name: CI (master)
22

33
on:
4-
# Runs on every push to the master branch.
54
push:
65
branches:
76
- master
87
tags-ignore:
9-
- "**" # Ignore all tags to avoid duplicate executions triggered by tag pushes.
8+
- "**" # Ignore all tags to avoid duplicate executions triggered by tag pushes.
9+
10+
concurrency:
11+
group: release
12+
cancel-in-progress: false
1013

1114
jobs:
1215
doc_checks:
1316
name: Doc checks
1417
uses: ./.github/workflows/_check_docs.yaml
15-
secrets: inherit
18+
secrets:
19+
APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }}
20+
21+
doc_release:
22+
# Skip this for non-docs commits and forks.
23+
if: "startsWith(github.event.head_commit.message, 'docs') && startsWith(github.repository, 'apify/')"
24+
name: Doc release
25+
needs: [doc_checks]
26+
uses: ./.github/workflows/_release_docs.yaml
27+
with:
28+
# Use the same ref as the one that triggered the workflow.
29+
ref: ${{ github.ref }}
30+
secrets:
31+
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
32+
APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }}
33+
SEGMENT_TOKEN: ${{ secrets.SEGMENT_TOKEN }}
1634

1735
code_checks:
1836
name: Code checks
1937
uses: ./.github/workflows/_check_code.yaml
2038

2139
tests:
40+
# Skip this for "ci" and "docs" commits.
41+
if: "!startsWith(github.event.head_commit.message, 'ci') && !startsWith(github.event.head_commit.message, 'docs')"
2242
name: Tests
2343
uses: ./.github/workflows/_tests.yaml
24-
secrets: inherit
44+
secrets:
45+
APIFY_HTTPBIN_TOKEN: ${{ secrets.APIFY_HTTPBIN_TOKEN }}
46+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2547

26-
pre_release:
27-
name: Pre-release
48+
release_prepare:
49+
# Skip this for "ci", "docs" and "test" commits and for forks.
50+
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/')"
51+
name: Release prepare
2852
needs: [code_checks, tests]
29-
uses: ./.github/workflows/_release_pre.yaml
30-
secrets: inherit
53+
runs-on: ubuntu-latest
54+
outputs:
55+
version_number: ${{ steps.release_prepare.outputs.version_number }}
56+
tag_name: ${{ steps.release_prepare.outputs.tag_name }}
57+
changelog: ${{ steps.release_prepare.outputs.changelog }}
58+
steps:
59+
- uses: apify/workflows/git-cliff-release@main
60+
id: release_prepare
61+
name: Release prepare
62+
with:
63+
release_type: prerelease
64+
existing_changelog_path: CHANGELOG.md
3165

32-
release_docs:
33-
name: Doc release
34-
needs: [doc_checks, pre_release]
66+
changelog_update:
67+
name: Changelog update
68+
needs: [release_prepare]
69+
uses: apify/workflows/.github/workflows/python_bump_and_update_changelog.yaml@main
70+
with:
71+
version_number: ${{ needs.release_prepare.outputs.version_number }}
72+
changelog: ${{ needs.release_prepare.outputs.changelog }}
73+
secrets:
74+
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
75+
76+
pypi_publish:
77+
name: PyPI publish
78+
needs: [release_prepare, changelog_update]
79+
runs-on: ubuntu-latest
80+
permissions:
81+
contents: write
82+
id-token: write # Required for OIDC authentication.
83+
environment:
84+
name: pypi
85+
url: https://pypi.org/project/crawlee
86+
steps:
87+
- name: Prepare distribution
88+
uses: apify/workflows/prepare-pypi-distribution@main
89+
with:
90+
package_name: crawlee
91+
is_prerelease: "yes"
92+
version_number: ${{ needs.release_prepare.outputs.version_number }}
93+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
94+
95+
- name: Publish package to PyPI
96+
uses: pypa/gh-action-pypi-publish@release/v1
97+
98+
doc_release_post_publish:
99+
name: Doc release post publish
100+
needs: [changelog_update, pypi_publish]
35101
uses: ./.github/workflows/_release_docs.yaml
36102
with:
37-
ref: ${{ needs.pre_release.outputs.changelog_commitish }}
38-
secrets: inherit
103+
# Use the ref from the changelog update to include the updated changelog.
104+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
105+
secrets:
106+
APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
107+
APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }}
108+
SEGMENT_TOKEN: ${{ secrets.SEGMENT_TOKEN }}

.github/workflows/on_pull_request.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
pull_request:
66

77
jobs:
8-
check_pr_title:
9-
name: Check PR title
8+
pr_title_check:
9+
name: PR title check
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: amannn/[email protected]
@@ -16,7 +16,8 @@ jobs:
1616
doc_checks:
1717
name: Doc checks
1818
uses: ./.github/workflows/_check_docs.yaml
19-
secrets: inherit
19+
secrets:
20+
APIFY_SIGNING_TOKEN: ${{ secrets.APIFY_SIGNING_TOKEN }}
2021

2122
code_checks:
2223
name: Code checks
@@ -25,4 +26,6 @@ jobs:
2526
tests:
2627
name: Tests
2728
uses: ./.github/workflows/_tests.yaml
28-
secrets: inherit
29+
secrets:
30+
APIFY_HTTPBIN_TOKEN: ${{ secrets.APIFY_HTTPBIN_TOKEN }}
31+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/on_schedule_tests.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
schedule:
99
- cron: '0 6 * * *'
1010

11+
concurrency:
12+
group: scheduled-tests
13+
cancel-in-progress: false
14+
1115
env:
1216
NODE_VERSION: 22
1317
PYTHON_VERSION: 3.14

0 commit comments

Comments
 (0)