|
| 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 }} |
0 commit comments