forked from typeddjango/django-stubs
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bump version with github actions (#202)
- Loading branch information
Showing
5 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Version level to increase" | ||
required: true | ||
default: "minor" | ||
type: choice | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
|
||
jobs: | ||
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | ||
update-version: | ||
name: "Publish Python 🐍 distribution 📦 to PyPI" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install poetry | ||
run: | | ||
pipx install poetry | ||
poetry config virtualenvs.create true | ||
poetry config virtualenvs.in-project true | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
cache: "poetry" | ||
|
||
- name: Update version | ||
run: ./s/update-version ${{ inputs.version }} | ||
|
||
- name: Build | ||
run: poetry build | ||
|
||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
- name: Push changes | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git commit -am 'Increment version: ${{ inputs.version }}' | ||
git push |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.7.13 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env python3 | ||
# This script requires fastmod to be installed | ||
# fastmod: https://github.com/facebookincubator/fastmod | ||
|
||
from pathlib import Path | ||
import re | ||
import argparse | ||
import tomlkit | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("version_increment", choices=["major", "minor", "patch"]) | ||
args = parser.parse_args() | ||
|
||
pyproject_path = Path(".").parent.parent / "pyproject.toml" | ||
pyproject = pyproject_path.read_text() | ||
|
||
current_version = tomlkit.loads(pyproject)["tool"]["poetry"]["version"] | ||
|
||
major, minor, patch = [int(x) for x in current_version.split(".")] | ||
|
||
if args.version_increment == "major": | ||
major += 1 | ||
minor = 0 | ||
patch = 0 | ||
elif args.version_increment == "minor": | ||
minor += 1 | ||
patch = 0 | ||
elif args.version_increment == "patch": | ||
patch += 1 | ||
else: | ||
raise ValueError("Unexpected value") | ||
|
||
new_version = f"{major}.{minor}.{patch}" | ||
|
||
updated_pyproject = re.sub( | ||
r'^version = ".*"', f'version = "{new_version}"', pyproject, flags=re.MULTILINE | ||
) | ||
pyproject_path.write_text(updated_pyproject) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |