Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
61 changes: 61 additions & 0 deletions .github/workflows/pre-release.yaml
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 }}
Copy link

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

Copy link
Author

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?

Copy link

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

92 changes: 59 additions & 33 deletions .github/workflows/release.yaml
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 }}
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.12
3.11
37 changes: 36 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pyap-beauhurst"
version = "0.5.0"
version = "1999.1.1"
description = "Pyap is an MIT Licensed text processing library, written in Python, for detecting and parsing addresses. Currently it supports USA, Canadian and British addresses. This is a fork maintained by Beauhurst."
repository = "https://github.com/Beauhurst/pyap"
requires-python = ">=3.11,<3.14"
Expand Down Expand Up @@ -112,3 +112,38 @@ omit = ["tests/*"]

[tool.coverage.report]
show_missing = true

[tool.bumpversion]
current_version = "1999.1.1"
parse = """(?x) # Verbose mode
(?P<release> # The release part
(?:[1-9][0-9]{3})\\. # YYYY.
(?:1[0-2]|[1-9]) # MM.
)
\\.(?P<num>0|[1-9]\\d*) # num version number
(?:
-(?P<pre_label>dev|stable) # pre_release label
(?P<pre_release>0|[1-9]\\d*) # pre_release version number
)?
"""
serialize = ["{release}.{num}-{pre_label}{pre_release}", "{release}.{num}"]
search = "{current_version}"
replace = "{new_version}"
tag = true
tag_name = "v{new_version}"
tag_message = "v{new_version}"
commit = true
message = "v{new_version}"

[tool.bumpversion.parts.release]
calver_format = "{YYYY}.{MM}"

[tool.bumpversion.parts.num]
independent = false

[tool.bumpversion.parts.pre_label]
optional_value = "stable"
values = ["dev", "stable"]

[[tool.bumpversion.files]]
filename = "pyproject.toml"
43 changes: 43 additions & 0 deletions scripts/bump-version.sh
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.
Loading