Chore/release #17
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Tag on Merge | |
on: | |
pull_request: | |
types: [closed] | |
branches: | |
- main | |
permissions: | |
contents: write # Allow writing to the repo contents | |
jobs: | |
create-tag: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: anothrNick/github-tag-action@1.71.0 | |
name: Get next version | |
id: get_version | |
env: | |
DEFAULT_BUMP: patch | |
WITH_V: true | |
DEFAULT_BRANCH: main | |
RELEASE_BRANCHES: main | |
DRY_RUN: true # don't actually create tag, I want to create it after updating the python version file | |
- name: Update __version__.py | |
run: echo "__version__ = \"${{ steps.get_version.outputs.new_tag }}\"" > src/beeperpurge/__version__.py | |
- name: Update __init__.py | |
run: echo "__version__ = \"${{ steps.get_version.outputs.new_tag }}\"" > src/beeperpurge/__init__.py | |
- name: Update pyproject.toml | |
run: sed -i "s/^version = \".*\"/version = \"${{ steps.get_version.outputs.new_tag }}\"/" pyproject.toml | |
shell: bash | |
- name: Commit version update | |
uses: EndBug/add-and-commit@v9 | |
with: | |
author_name: GitHub Actions | |
author_email: actions@github.com | |
message: 'Update __version__.py' | |
add: '["src/beeperpurge/__version__.py", | |
"src/beeperpurge/__init__.py", | |
"pyproject.toml"]' | |
- name: Get version from package # We intentionally take the version from the updated file and not run github-tag-action again | |
id: get_version_from_file | |
run: | | |
PACKAGE_VERSION=$(python -c "from src.beeperpurge.__version__ import __version__; print(__version__)") | |
echo "version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT | |
- name: Create and push tag | |
run: | | |
git tag "${{ steps.get_version_from_file.outputs.version }}" | |
git push origin "${{ steps.get_version_from_file.outputs.version }}" |