Publish Release #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: Publish Release | |
on: | |
# Allow manual triggering of the workflow | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "The version of the release (e.g., 1.0.0)" | |
required: true | |
permissions: | |
id-token: write | |
contents: write | |
jobs: | |
release: | |
name: Release proto-schema-parser | |
runs-on: ubuntu-latest | |
steps: | |
# Verify the version is a valid SemVer version | |
- name: Verify version | |
id: semver | |
uses: matt-usurp/validate-semver@v2 | |
with: | |
version: ${{ github.event.inputs.version }} | |
# Checkout repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Set up PDM stable | |
- name: Install pdm | |
run: pip install pdm | |
# Set up TOML updater | |
- name: Install tomlkit | |
run: pip install update-toml | |
# Generate documentation | |
# Have to copy into a separate folder to remove `antlr` dir to exclude auto-generated code | |
- name: Generate documentation | |
run: | | |
pip install python-docstring-markdown | |
mkdir -p docs_tmp | |
cp -r src/proto_schema_parser docs_tmp | |
rm -rf docs_tmp/proto_schema_parser/antlr | |
python -m python_docstring_markdown docs_tmp/proto_schema_parser DOCUMENTATION.md | |
rm -rf docs_tmp | |
# Set pyproject.toml version using pdm | |
- name: Set version | |
run: update-toml update --path project.version --value ${{ github.event.inputs.version }} --file pyproject.toml | |
# Commit changes | |
- name: Commit config version bump | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: "Bump version to ${{ github.event.inputs.version }}" | |
push: true | |
# Publish a git release that creates a new "X.Y.Z" release tag and includes generated notes | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ github.event.inputs.version }} | |
name: ${{ github.event.inputs.version }} | |
generateReleaseNotes: true | |
# Publish the package to pypi | |
- name: Publish to PyPI | |
run: pdm publish |