Skip to content

Commit

Permalink
fix: add step to modify init.py and commit the change
Browse files Browse the repository at this point in the history
  • Loading branch information
drodarie committed Jul 19, 2024
1 parent 70c1bfa commit 3375942
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Create release
name: Bump version, create release and deploy

on:
push:
Expand All @@ -10,6 +10,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.semver.outputs.next }}
old_tag: ${{ steps.semver.outputs.current }}

steps:
- name: Checkout Code
Expand All @@ -23,6 +24,18 @@ jobs:
with:
token: ${{ github.token }}
branch: main
- name: Update __init__.py and pyproject.toml
run: |
replacev="\"${{steps.semver.outputs.next}}\""
newtag=$(echo $replacev | sed "s/v//g")
sed -i "s/__version__ = .*/__version__ = $newtag/g" test_actions/__init__.py
- name: Commit version change
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: main
commit_message: 'docs: bump version: ${{ steps.semver.outputs.current }} → ${{ github.ref_name }} [skip ci]'
file_pattern: test_actions/__init__.py

- uses: rickstaa/action-create-tag@v1
id: "tag_create"
Expand All @@ -40,20 +53,13 @@ jobs:
with:
fetch-depth: 0

- name: Get previous tag
id: previousTag
run: |
name=$(git --no-pager tag --sort=creatordate --merged ${{ needs.bump.outputs.tag }} | tail -2 | head -1)
echo "previousTag: $name"
echo "previousTag=$name" >> $GITHUB_ENV
- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
fromTag: ${{ needs.bump.outputs.tag }}
toTag: ${{ env.previousTag }}
toTag: ${{ needs.bump.outputs.old_tag }}

- name: Create Release
uses: ncipollo/[email protected]
Expand Down
27 changes: 1 addition & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,11 @@ test = [
dev = [
"pre-commit~=3.5",
"black~=24.0",
"isort~=5.12",
"bump-my-version~=0.21"
"isort~=5.12"
]

[tool.black]
line-length = 100

[tool.isort]
profile = "black"

[tool.bumpversion]
current_version = "0.0.2"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
replace = "{new_version}"
regex = false
ignore_missing_version = false
tag = true
sign_tags = false
tag_name = "v{new_version}"
tag_message = "Bump version: {current_version} → {new_version}"
allow_dirty = false
commit = true
message = "Bump version: {current_version} → {new_version}"
commit_args = "--no-verify"

[tool.bumpversion.parts.pre_l]
values = ["dev", "a", "b", "rc", "final"]
optional_value = "final"

[[tool.bumpversion.files]]
filename = "test_actions/__init__.py"
2 changes: 1 addition & 1 deletion test_actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Test python package to test Github actions
"""

__version__ = "0.0.2"
__version__ = "1.0.1"

0 comments on commit 3375942

Please sign in to comment.