diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index babd4e5..6eee471 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,4 +35,4 @@ jobs: run: uv sync --dev - name: Run Tests - run: uv run ./scripts/run-tests.sh + run: uv run ./run-tests.sh diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml deleted file mode 100644 index f98481e..0000000 --- a/.github/workflows/pre-release.yaml +++ /dev/null @@ -1,61 +0,0 @@ -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 }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d119071..018ad24 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,21 +1,18 @@ name: Tag & Release on: - pull_request: - types: - - "closed" + push: branches: - - "main" + - 'main' jobs: - build_and_release: - if: github.event.pull_request.merged == true && !startsWith(github.head_ref, 'release') + build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install uv - uses: astral-sh/setup-uv@v6 + uses: astral-sh/setup-uv@v2 with: enable-cache: true @@ -24,15 +21,8 @@ jobs: with: python-version-file: ".python-version" - - name: Bump version - 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: Install dev dependencies + run: uv sync --dev - name: Build binary wheel and a source tarball run: | @@ -40,42 +30,29 @@ jobs: --package pyap_beauhurst \ --out-dir dist - - 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" - - # create release PR - gh pr create \ - --title "Release $TAG_NAME" \ - --head "$(git branch --show-current)" \ - --fill \ - --base main + - name: Get version + run: echo "VERSION=$(uv version --short)" >>$GITHUB_OUTPUT + id: version - - name: Merge it - env: - TAG_NAME: "v${{ steps.version.outputs.VERSION }}" - GH_TOKEN: ${{ secrets.GA_PAT }} - run: | - # Merge PR - gh pr merge --admin --squash + - 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: Create a GitHub Release - uses: softprops/action-gh-release@v2 + - name: Create a GitHub release and upload artifact + uses: ncipollo/release-action@v1 with: - prerelease: false + 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 }} - generate_release_notes: true - files: "./dist/pyap_beauhurst-*" - make_latest: true - tag_name: ${{ steps.version.outputs.VERSION }} + + - name: Latest tag + uses: EndBug/latest-tag@v1 - name: Publish to pypi run: | - uv publish --token ${{ secrets.PYPI_TOKEN }} \ No newline at end of file + uv publish --token ${{ secrets.PYPI_TOKEN }} diff --git a/.python-version b/.python-version index 2c07333..3b564fa 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.11 +3.11.12 diff --git a/pyproject.toml b/pyproject.toml index f7a6671..aa2034b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pyap-beauhurst" -version = "1999.1.1" +version = "0.5.0" 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" @@ -112,38 +112,3 @@ omit = ["tests/*"] [tool.coverage.report] show_missing = true - -[tool.bumpversion] -current_version = "1999.1.1" -parse = """(?x) # Verbose mode - (?P # The release part - (?:[1-9][0-9]{3})\\. # YYYY. - (?:1[0-2]|[1-9]) # MM. - ) - \\.(?P0|[1-9]\\d*) # num version number - (?: - -(?Pdev|stable) # pre_release label - (?P0|[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" diff --git a/scripts/run-tests.sh b/run-tests.sh similarity index 100% rename from scripts/run-tests.sh rename to run-tests.sh diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh deleted file mode 100755 index 0eced51..0000000 --- a/scripts/bump-version.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/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"