Skip to content

Commit 30f8e15

Browse files
authored
chore(ci): Refactor release workflows and secrets handling (#1620)
1 parent bf4a196 commit 30f8e15

File tree

7 files changed

+103
-112
lines changed

7 files changed

+103
-112
lines changed

.github/workflows/_check_docs.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ jobs:
1111
doc_checks:
1212
name: Doc checks
1313
uses: apify/workflows/.github/workflows/python_docs_check.yaml@main
14-
secrets: inherit

.github/workflows/_release_docs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
env:
1515
NODE_VERSION: 22
1616
PYTHON_VERSION: 3.14
17+
CHECKOUT_REF: ${{ github.event_name == 'workflow_call' && inputs.ref || github.ref }}
1718

1819
jobs:
1920
release_docs:
@@ -31,7 +32,7 @@ jobs:
3132
uses: actions/checkout@v6
3233
with:
3334
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
34-
ref: ${{ github.event_name == 'workflow_call' && inputs.ref || github.ref }}
35+
ref: ${{ env.CHECKOUT_REF }}
3536

3637
- name: Set up Node
3738
uses: actions/setup-node@v6

.github/workflows/_release_pre.yaml

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

.github/workflows/manual_release_stable.yaml

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,51 @@ 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 }}
58-
secrets:
59-
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
6059

61-
create_github_release:
62-
name: Create GitHub release
63-
needs: [release_metadata, update_changelog]
60+
github_release:
61+
name: GitHub release
62+
needs: [release_prepare, changelog_update]
6463
runs-on: ubuntu-latest
6564
env:
6665
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6766
steps:
68-
- name: Create release
67+
- name: GitHub release
6968
uses: softprops/action-gh-release@v2
7069
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 }}
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 }}
7574

76-
publish_to_pypi:
77-
name: Publish to PyPI
78-
needs: [release_metadata, update_changelog]
75+
pypi_publish:
76+
name: PyPI publish
77+
needs: [release_prepare, changelog_update]
7978
runs-on: ubuntu-latest
8079
permissions:
8180
contents: write
@@ -89,8 +88,8 @@ jobs:
8988
with:
9089
package_name: crawlee
9190
is_prerelease: ""
92-
version_number: ${{ needs.release_metadata.outputs.version_number }}
93-
ref: ${{ needs.update_changelog.outputs.changelog_commitish }}
91+
version_number: ${{ needs.release_prepare.outputs.version_number }}
92+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
9493
# Publishes the package to PyPI using PyPA official GitHub action with OIDC authentication.
9594
- name: Publish package to PyPI
9695
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/on_master.yaml

Lines changed: 68 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,97 @@
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
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 }}
1528
secrets: inherit
1629

1730
code_checks:
1831
name: Code checks
1932
uses: ./.github/workflows/_check_code.yaml
2033

2134
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')"
2237
name: Tests
2338
uses: ./.github/workflows/_tests.yaml
2439
secrets: inherit
2540

26-
pre_release:
27-
name: Pre-release
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
2845
needs: [code_checks, tests]
29-
uses: ./.github/workflows/_release_pre.yaml
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 }}
3066
secrets: inherit
3167

32-
release_docs:
33-
name: Doc release
34-
needs: [doc_checks, pre_release]
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/crawlee
78+
steps:
79+
- name: Prepare distribution
80+
uses: apify/workflows/prepare-pypi-distribution@main
81+
with:
82+
package_name: crawlee
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]
3593
uses: ./.github/workflows/_release_docs.yaml
3694
with:
37-
ref: ${{ needs.pre_release.outputs.changelog_commitish }}
95+
# Use the ref from the changelog update to include the updated changelog.
96+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
3897
secrets: inherit

.github/workflows/on_pull_request.yaml

Lines changed: 2 additions & 3 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,6 @@ jobs:
1616
doc_checks:
1717
name: Doc checks
1818
uses: ./.github/workflows/_check_docs.yaml
19-
secrets: inherit
2019

2120
code_checks:
2221
name: Code checks

.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)