diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml new file mode 100644 index 0000000..1492076 --- /dev/null +++ b/.github/workflows/bump-version.yml @@ -0,0 +1,84 @@ +name: Bump Version +on: + workflow_dispatch: + inputs: + version_part: + description: 'Version part to bump (major, minor, patch)' + required: true + default: 'patch' + type: choice + options: + - major + - minor + - patch + +jobs: + bump-version: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install bumpversion + run: | + python -m pip install --upgrade pip + pip install bump2version + + - name: Configure git + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + - name: Get current version + id: current_version + run: | + echo "version=$(grep current_version .bumpversion.cfg | cut -d '=' -f 2 | tr -d ' ')" >> $GITHUB_OUTPUT + + - name: Bump version + id: bump_version + run: | + # Use --no-tag to prevent creating a tag (we'll tag after PR merge) + # Use --no-commit to let create-pull-request handle the commit + bump2version ${{ github.event.inputs.version_part }} --no-tag --no-commit + echo "new_version=$(grep current_version .bumpversion.cfg | cut -d '=' -f 2 | tr -d ' ')" >> $GITHUB_OUTPUT + + - name: Create Pull Request + id: create_pr + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: bump version from ${{ steps.current_version.outputs.version }} to ${{ steps.bump_version.outputs.new_version }}" + title: "chore: bump version from ${{ steps.current_version.outputs.version }} to ${{ steps.bump_version.outputs.new_version }}" + body: | + ## Version Bump + + This PR bumps the version from `${{ steps.current_version.outputs.version }}` to `${{ steps.bump_version.outputs.new_version }}`. + + ### Changes + - Updated version in `setup.py` + - Updated version in `docs/conf.py` + - Updated version in `src/datapilot/__init__.py` + - Updated version in `.bumpversion.cfg` + + ### Type of change + - Version bump (${{ github.event.inputs.version_part }}) + + --- + *This PR was automatically created by the bump version workflow.* + branch: bump-version-${{ steps.bump_version.outputs.new_version }} + delete-branch: true + labels: | + version-bump + automated diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.yml new file mode 100644 index 0000000..19e3d6e --- /dev/null +++ b/.github/workflows/tag-release.yml @@ -0,0 +1,49 @@ +name: Tag Release +on: + pull_request: + types: [closed] + branches: [main] + +jobs: + tag-release: + if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'version-bump') + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox twine wheel setuptools + + - name: Get version from file + id: get_version + run: | + echo "version=$(grep current_version .bumpversion.cfg | cut -d '=' -f 2 | tr -d ' ')" >> $GITHUB_OUTPUT + + - name: Create and push tag + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git tag -a "v${{ steps.get_version.outputs.version }}" -m "Release version ${{ steps.get_version.outputs.version }}" + git push origin "v${{ steps.get_version.outputs.version }}" + + - name: Make release script executable + run: chmod +x release.sh + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: ./release.sh