-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate automated PyPI releases into CI #125
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Publish to PyPI | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
publish_to_pypi: | ||
name: Publish to PyPI | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/project/crawlee | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Install dependencies | ||
run: make install-dev | ||
|
||
# Determines the release type based on the event that triggered the workflow. | ||
- name: Determine release type | ||
id: determine-release-type | ||
run: | | ||
if [[ ${{ github.event_name }} = release ]]; then | ||
release_type="final" | ||
elif [[ ${{ github.event_name }} = push ]]; then | ||
release_type="beta" | ||
elif [[ ${{ github.event_name }} = workflow_dispatch ]]; then | ||
release_type=${{ github.event.inputs.release_type }} | ||
fi | ||
echo "release_type=${release_type}" >> $GITHUB_OUTPUT | ||
|
||
# Updates the version number for pre-releases in the project's configuration. | ||
- name: Set pre-release version | ||
if: steps.determine-release-type.outputs.release_type != 'final' | ||
run: python ./scripts/update_version_for_prerelease.py ${{ steps.determine-release-type.outputs.release_type }} | ||
|
||
# Builds and publishes the package to PyPI, using OIDC for PyPI authentication. | ||
- name: Build & publish package to PyPI | ||
run: poetry publish --build --no-interaction -vv | ||
|
||
# If this workflow is not triggered by a GitHub release event, manually create and push a Git tag. | ||
- name: Create Git tag with the published version | ||
if: github.event_name != 'release' | ||
run: | | ||
GIT_TAG=v$(python ./scripts/print_current_package_version.py) | ||
git tag "$GIT_TAG" | ||
git push origin $git_tag | ||
|
||
# If triggered by a release, upload build artifacts to the associated GitHub release. | ||
- name: Upload the build artifacts to release | ||
if: github.event_name == 'release' | ||
run: gh release upload ${{ github.ref_name }} dist/* | ||
env: | ||
GH_TOKEN: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Run release | ||
|
||
on: | ||
# Trigger a beta version release (pre-release) on push to the master branch. | ||
push: | ||
branches: | ||
- master | ||
tags-ignore: | ||
- "**" # Ignore all tags to prevent duplicate builds when tags are pushed. | ||
|
||
# Trigger a stable version release when a GitHub release is published. | ||
release: | ||
types: [published] | ||
|
||
# Allows manual workflow runs from GitHub's UI, with the ability to specify the type of release. | ||
workflow_dispatch: | ||
inputs: | ||
release_type: | ||
description: Release type | ||
required: true | ||
type: choice | ||
default: alpha | ||
options: | ||
- alpha | ||
- beta | ||
- final | ||
|
||
jobs: | ||
run_code_checks: | ||
name: Run code checks | ||
uses: ./.github/workflows/run_code_checks.yaml | ||
|
||
publish_to_pypi: | ||
name: Publish to PyPI | ||
needs: [run_code_checks] | ||
uses: ./.github/workflows/_publish_to_pypi.yaml | ||
|
||
# TODO: add job for publish package to Conda | ||
# https://github.com/apify/crawlee-py/issues/104 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine for now, but in the long run i would like to see similar mechanism as we have in crawlee - stable releases are triggered via workflow dispatch, and they modify the changelog as well as create the git tag and its corresponding GH release notes. as if you would trigger this by creating a GH release first, it means you are responsible for creating the changelog - i know there is button in the UI for that nowadays, but it ignores commits to master and doesn't handle conventional commits properly (e.g. it adds everything including chore commits)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK this is copied from python SDK, do we want to make those changes in both repos?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will be done later as part of #18
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, ideally, we will migrate all repositories to the new system, but we agreed with Vlada to keep this as is for now and deal with this later (even after the public launch, functionality has priority over this). Also @vladfrangu should prepare a new mechanism for releasing the CLI which might help here too, as it should do the same, workflow dispatch will trigger changelog update and create new git tag and gh release, and this part should work the same regardless of the language.