forked from LeapBeyond/pyap
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix release workflow #11
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -35,4 +35,4 @@ jobs: | |
| run: uv sync --dev | ||
|
|
||
| - name: Run Tests | ||
| run: uv run ./run-tests.sh | ||
| run: uv run ./scripts/run-tests.sh | ||
This file contains hidden or 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,61 @@ | ||
| name: Tag & Pre-Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - "prerelease-*" | ||
|
|
||
| jobs: | ||
| build_and_pre_release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v6 | ||
| with: | ||
| enable-cache: true | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version-file: ".python-version" | ||
|
|
||
| - name: Bump version | ||
| env: | ||
| PRE_RELEASE: "true" | ||
| run: | | ||
| git config user.name "Release Bot" | ||
| git config user.email "dev@beauhurst.com" | ||
| ./scripts/bump-version.sh | ||
|
|
||
| - name: Get new version | ||
| id: version | ||
| run: echo "VERSION=$(uvx --from toml-cli toml get --toml-path pyproject.toml project.version)" >>$GITHUB_OUTPUT | ||
|
|
||
| - name: Build binary wheel and a source tarball | ||
| run: | | ||
| uv build \ | ||
| --package pyap_beauhurst \ | ||
| --out-dir dist | ||
|
|
||
| - name: Push version & tag to repository | ||
| env: | ||
| TAG_NAME: "v${{ steps.version.outputs.VERSION }}" | ||
| run: | | ||
| git push | ||
| git push origin tag "$TAG_NAME" | ||
|
|
||
| - name: Create a GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| prerelease: true | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| generate_release_notes: true | ||
| files: "./dist/pyap_beauhurst-*" | ||
| make_latest: false | ||
| tag_name: ${{ steps.version.outputs.VERSION }} | ||
|
|
||
| - name: Publish to pypi | ||
| run: | | ||
| uv publish --token ${{ secrets.PYPI_TOKEN }} | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,55 +1,81 @@ | ||
| name: Tag & Release | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| types: | ||
| - "closed" | ||
| branches: | ||
| - 'main' | ||
| - "main" | ||
|
|
||
| jobs: | ||
| build: | ||
| build_and_release: | ||
| if: github.event.pull_request.merged == true && !startsWith(github.head_ref, 'release') | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v6 | ||
| with: | ||
| python-version: '3.8' | ||
| enable-cache: true | ||
|
|
||
| - name: Install dev dependencies | ||
| run: python -m pip install --upgrade pip setuptools poetry | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version-file: ".python-version" | ||
|
|
||
| - name: Build binary wheel and a source tarball | ||
| run: poetry build | ||
| - name: Bump version | ||
| run: | | ||
| git config user.name "Release Bot" | ||
| git config user.email "dev@beauhurst.com" | ||
| ./scripts/bump-version.sh | ||
|
|
||
| - name: Get version | ||
| run: echo "VERSION=$(poetry version --short)" >>$GITHUB_OUTPUT | ||
| - name: Get new version | ||
| id: version | ||
| run: echo "VERSION=$(uvx --from toml-cli toml get --toml-path pyproject.toml project.version)" >>$GITHUB_OUTPUT | ||
|
|
||
| - name: Tag with updated version | ||
| id: tag_version | ||
| uses: mathieudutour/github-tag-action@v6.1 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| custom_tag: ${{ steps.version.outputs.VERSION }} | ||
| - name: Build binary wheel and a source tarball | ||
| run: | | ||
| uv build \ | ||
| --package pyap_beauhurst \ | ||
| --out-dir dist | ||
|
|
||
| - name: Create a GitHub release and upload artifact | ||
| uses: ncipollo/release-action@v1 | ||
| with: | ||
| tag: ${{ steps.tag_version.outputs.new_tag }} | ||
| name: Release ${{ steps.tag_version.outputs.new_tag }} | ||
| generateReleaseNotes: true | ||
| artifacts: './dist/pyap_beauhurst-${{ steps.tag_version.outputs.new_version }}.tar.gz,./dist/pyap_beauhurst-${{ steps.tag_version.outputs.new_version }}-py3-none-any.whl' | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Create release branch, push branch, tag and create PR | ||
| env: | ||
| TAG_NAME: "v${{ steps.version.outputs.VERSION }}" | ||
| BRANCH_NAME: "release-v${{ steps.version.outputs.VERSION }}" | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
|
|
||
| git checkout -b "$BRANCH_NAME" | ||
| git push origin "$BRANCH_NAME" | ||
| git push origin tag "$TAG_NAME" | ||
|
|
||
| - name: Latest tag | ||
| uses: EndBug/latest-tag@v1 | ||
| # create release PR | ||
| gh pr create \ | ||
| --title "Release $TAG_NAME" \ | ||
| --head "$(git branch --show-current)" \ | ||
| --fill \ | ||
| --base main | ||
|
|
||
| - name: Configure pypi credentials | ||
| - name: Merge it | ||
| env: | ||
| PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | ||
| TAG_NAME: "v${{ steps.version.outputs.VERSION }}" | ||
| GH_TOKEN: ${{ secrets.GA_PAT }} | ||
| run: | | ||
| poetry config pypi-token.pypi "$PYPI_TOKEN" | ||
| # Merge PR | ||
| gh pr merge --admin --squash | ||
|
|
||
| - name: Create a GitHub Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| prerelease: false | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| generate_release_notes: true | ||
| files: "./dist/pyap_beauhurst-*" | ||
| make_latest: true | ||
| tag_name: ${{ steps.version.outputs.VERSION }} | ||
|
|
||
| - name: Publish to pypi | ||
| run: | | ||
| poetry publish | ||
| uv publish --token ${{ secrets.PYPI_TOKEN }} |
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1 @@ | ||
| 3.11.12 | ||
| 3.11 |
This file contains hidden or 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 hidden or 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,43 @@ | ||
| #!/bin/sh | ||
| set -x -e | ||
|
|
||
| # This defines the canonical way of bumping version | ||
| case "$PRE_RELEASE" in | ||
| true | 1) | ||
| echo "Bumping version for pre-release" | ||
| CURRENT_VERSION="$(uvx --from toml-cli toml get --toml-path pyproject.toml project.version)" | ||
| case "$CURRENT_VERSION" in | ||
| *dev*) | ||
| #2024.9.1-dev0 -> #2024.9.1-dev1 | ||
| uvx --from bump-my-version bump-my-version bump pre_release | ||
| ;; | ||
| *) | ||
| #2024.9.0 -> #2024.9.1-dev0 | ||
| uvx --from bump-my-version bump-my-version bump num | ||
| ;; | ||
| esac | ||
| ;; | ||
| *) | ||
| echo "Bumping version for release" | ||
|
|
||
| # find if we can bump just the label | ||
| # this will fail when pre_label bumping cannot be done (i.e. it's already stable) | ||
| # this will succeed but include dev it if is bumping the calver section | ||
| POTENTIAL_NEW_VERSION="$(uvx --from bump-my-version bump-my-version show -i pre_label new_version 2>/dev/null || echo 'error')" | ||
| case "$POTENTIAL_NEW_VERSION" in | ||
| error | *dev*) | ||
| #2024.9.0 -> #2024.9.1 | ||
| uvx --from bump-my-version bump-my-version bump num --no-commit --no-tag | ||
| uvx --from bump-my-version bump-my-version bump pre_label --allow-dirty | ||
| ;; | ||
| *) | ||
| #2024.9.1-dev0 -> #2024.9.1 | ||
| uvx --from bump-my-version bump-my-version bump pre_label | ||
| ;; | ||
| esac | ||
| ;; | ||
| esac | ||
|
|
||
| NEW_VERSION="$(uvx --from toml-cli toml get --toml-path pyproject.toml project.version)" | ||
|
|
||
| echo "$NEW_VERSION" |
File renamed without changes.
Oops, something went wrong.
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.
does this work? we use twine in the other ones
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.
its just taken from here https://docs.astral.sh/uv/guides/package/#publishing-your-package
happy to swap for twine if you prefer? maybe lets merge it and find out?
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.
no this is great! i think that didn't exist before