Merge pull request #1 from DefensiveOrigins/main #2
This file contains hidden or 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-bump version, release, and publish | |
| on: | |
| push: | |
| branches: | |
| - Publish | |
| permissions: | |
| contents: write | |
| jobs: | |
| bump-release-publish: | |
| name: Auto-bump version and publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| 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 | |
| python -m pip install build twine toml | |
| - name: Auto-increment version | |
| id: bump | |
| run: | | |
| python - << 'PY' | |
| import toml | |
| from pathlib import Path | |
| path = Path("pyproject.toml") | |
| data = toml.loads(path.read_text()) | |
| version = data["project"]["version"] | |
| major, minor, patch = version.split(".") | |
| patch = str(int(patch) + 1) | |
| new_version = ".".join([major, minor, patch]) | |
| data["project"]["version"] = new_version | |
| path.write_text(toml.dumps(data)) | |
| print(f"Bumped version: {version} -> {new_version}") | |
| # Export for later steps | |
| with open(Path("$GITHUB_OUTPUT"), "a") as f: | |
| f.write(f"new_version={new_version}\n") | |
| PY | |
| - name: Commit updated version | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "[email protected]" | |
| git add pyproject.toml | |
| git commit -m "Auto-bump version to ${{ steps.bump.outputs.new_version }}" | |
| git push | |
| - name: Build distributions | |
| run: | | |
| python -m build | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: "__token__" | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| twine upload dist/* | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.bump.outputs.new_version }} | |
| name: nessus-plugin-hosts v${{ steps.bump.outputs.new_version }} | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |