diff --git a/.github/workflows/bump.yaml b/.github/workflows/bump.yaml new file mode 100644 index 0000000..a34d1aa --- /dev/null +++ b/.github/workflows/bump.yaml @@ -0,0 +1,47 @@ +name: Bump version + +on: + workflow_dispatch: + inputs: + bump: + description: "Version component to bump" + type: choice + options: [major, minor, patch, stable, alpha, beta, rc, post, dev] + default: patch + +permissions: + contents: write + pull-requests: write + +jobs: + bump: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + + - name: Install uv + uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2 + + - name: Bump version + run: | + uv version --bump ${{ inputs.bump }} + echo "VERSION=$(uv version --short)" >> "$GITHUB_ENV" + + - name: Open release PR + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + BRANCH="release/v${VERSION}" + git switch -c "$BRANCH" + git commit -am "Release v${VERSION}" + git push --force-with-lease origin "$BRANCH" + + gh pr create \ + --base main \ + --head "$BRANCH" \ + --title "Release v${VERSION}" \ + --body "Automated version bump to \`v${VERSION}\`." diff --git a/src/dstrack/__init__.py b/src/dstrack/__init__.py index 44c1685..581bcdc 100644 --- a/src/dstrack/__init__.py +++ b/src/dstrack/__init__.py @@ -1,3 +1,8 @@ +from importlib.metadata import PackageNotFoundError, version + from . import _logging as _logging -__version__ = "0.1.0" +try: + __version__ = version("dstrack") +except PackageNotFoundError: + __version__ = "unknown"