1414 runs-on : ubuntu-latest
1515
1616 steps :
17- - name : Check out repository
17+ - name : Check out Publish branch
1818 uses : actions/checkout@v4
1919 with :
2020 fetch-depth : 0
@@ -24,47 +24,45 @@ jobs:
2424 with :
2525 python-version : " 3.11"
2626
27- - name : Install dependencies
27+ - name : Install tools
2828 run : |
2929 python -m pip install --upgrade pip
3030 python -m pip install build twine toml
3131
32- - name : Auto-increment version
32+ - name : Auto-increment version in pyproject.toml
3333 id : bump
3434 run : |
3535 python - << 'PY'
3636 import toml
3737 from pathlib import Path
3838
3939 path = Path("pyproject.toml")
40- data = toml.loads(path.read_text())
40+ data = toml.loads(path.read_text(encoding="utf-8" ))
4141
4242 version = data["project"]["version"]
43-
4443 major, minor, patch = version.split(".")
4544 patch = str(int(patch) + 1)
4645 new_version = ".".join([major, minor, patch])
4746
4847 data["project"]["version"] = new_version
49-
50- path.write_text(toml.dumps(data))
48+ path.write_text(toml.dumps(data), encoding="utf-8")
5149
5250 print(f"Bumped version: {version} -> {new_version}")
5351
54- # Export for later steps
55- with open(Path("$GITHUB_OUTPUT"), "a") as f:
52+ # Expose for later steps
53+ with open(Path("$GITHUB_OUTPUT"), "a", encoding="utf-8" ) as f:
5654 f.write(f"new_version={new_version}\n")
5755 PY
5856
59- - name : Commit updated version
57+ - name : Commit bumped version on Publish
6058 run : |
6159 git config user.name "github-actions"
6260 git config user.email "actions@github.com"
6361 git add pyproject.toml
64- git commit -m "Auto-bump version to ${{ steps.bump.outputs.new_version }}"
65- git push
62+ git commit -m "Auto-bump version to ${{ steps.bump.outputs.new_version }}" || echo "No changes to commit"
63+ git push origin Publish || echo "No changes pushed"
6664
67- - name : Build distributions
65+ - name : Build distributions from Publish
6866 run : |
6967 python -m build
7068
@@ -75,11 +73,28 @@ jobs:
7573 run : |
7674 twine upload dist/*
7775
78- - name : Create GitHub release
76+ - name : Create GitHub Release
7977 uses : softprops/action-gh-release@v2
8078 with :
8179 tag_name : v${{ steps.bump.outputs.new_version }}
8280 name : nessus-plugin-hosts v${{ steps.bump.outputs.new_version }}
8381 generate_release_notes : true
8482 env :
85- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
83+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
84+
85+ - name : Sync bumped version back to main
86+ run : |
87+ # Make sure we have the latest branches
88+ git fetch origin
89+
90+ # Switch to main branch
91+ git switch main
92+ git pull origin main
93+
94+ # Bring pyproject.toml from Publish into main
95+ git checkout origin/Publish -- pyproject.toml
96+
97+ # Commit only if there are changes
98+ git add pyproject.toml
99+ git commit -m "Sync version from Publish: ${{ steps.bump.outputs.new_version }}" || echo "No version changes to sync"
100+ git push origin main || echo "No changes pushed to main"
0 commit comments