diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8b59d21 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish to PyPI + +on: + release: + types: [published] + workflow_dispatch: + +permissions: + contents: read + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + + - name: Set up Python + run: uv python install 3.12 + + - name: Build package + run: uv build + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml new file mode 100644 index 0000000..101d006 --- /dev/null +++ b/.github/workflows/version-bump.yml @@ -0,0 +1,73 @@ +name: Bump Version + +on: + workflow_dispatch: + inputs: + bump_type: + description: 'Version bump type' + required: true + type: choice + options: + - patch + - minor + - major + - custom + default: 'patch' + custom_version: + description: 'Custom version (only used if bump_type is "custom")' + required: false + type: string + +permissions: + contents: write + +jobs: + bump-version: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install bump2version + run: pip install bump2version + + - name: Configure git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Bump version + run: | + if [ "${{ inputs.bump_type }}" = "custom" ]; then + if [ -z "${{ inputs.custom_version }}" ]; then + echo "Error: Custom version not provided" + exit 1 + fi + current_version=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') + sed -i "s/version = \"$current_version\"/version = \"${{ inputs.custom_version }}\"/" pyproject.toml + git add pyproject.toml + git commit -m "Bump version to ${{ inputs.custom_version }}" + echo "NEW_VERSION=${{ inputs.custom_version }}" >> $GITHUB_ENV + else + bump2version ${{ inputs.bump_type }} --current-version $(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') --config-file /dev/null --no-tag --no-commit pyproject.toml + new_version=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') + git add pyproject.toml + git commit -m "Bump version to $new_version (${{ inputs.bump_type }})" + echo "NEW_VERSION=$new_version" >> $GITHUB_ENV + fi + + - name: Push changes + run: git push + + - name: Output new version + run: | + echo "Version bumped successfully!" + echo "New version: ${{ env.NEW_VERSION }}" + echo "::notice::Version updated to ${{ env.NEW_VERSION }}"