From 8f2df6a842b459699ff84e3820a27d1222d1f291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Tue, 17 Jan 2023 11:58:39 +0100 Subject: [PATCH] ci: better github release management with scriv In scriv 1.1.0 the GitHub release description can be templated: https://github.com/nedbat/scriv/issues/61 https://github.com/nedbat/scriv/releases/tag/1.1.0 This means that we can finally get rid of our ugly scripts to generate the release description \o/ --- .github/workflows/release.yml | 11 ++------ Makefile | 27 +++++++------------ changelog.d/scriv.ini | 5 ++-- .../scriv/github_release.md.j2 | 5 ++-- requirements/base.txt | 8 +++--- requirements/dev.txt | 10 ++++--- requirements/docs.txt | 8 ++++-- 7 files changed, 36 insertions(+), 38 deletions(-) rename docs/_release_description.md => changelog.d/scriv/github_release.md.j2 (73%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5dcd12..9ff351e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,16 +70,9 @@ jobs: ##### Create release on GitHub - name: Create or update GitHub release - # I wish there was an `--update` option to the `gh release create` command, but - # there isn't. - # https://cli.github.com/manual/gh_release_create - run: | - make release-description | tee release_description.md - export GH_ARGS="${{ github.ref_name }} --notes-file=release_description.md" - echo "gh args: '$GH_ARGS'" - ${{ env.gh_bin }} release create $GH_ARGS || ${{ env.gh_bin }} release edit $GH_ARGS + run: scriv github-release env: - GH_TOKEN: ${{ github.token }} + GITHUB_TOKEN: ${{ github.token }} - name: Upload release asset to GitHub run: | export FILENAME="tutor-$(uname -s)_$(uname -m)" diff --git a/Makefile b/Makefile index fdd9a1c..9dbdeb7 100644 --- a/Makefile +++ b/Makefile @@ -54,12 +54,11 @@ format: ## Format code automatically isort: ## Sort imports. This target is not mandatory because the output may be incompatible with black formatting. Provided for convenience purposes. isort --skip=templates ${SRC_DIRS} -bootstrap-dev: ## Install dev requirements - pip install . - pip install -r requirements/dev.txt +changelog-entry: ## Create a new changelog entry + scriv create -bootstrap-dev-plugins: bootstrap-dev ## Install dev requirements and all supported plugins - pip install -r requirements/plugins.txt +changelog: ## Collect changelog entries in the CHANGELOG.md file + scriv collect ###### Code coverage @@ -78,23 +77,17 @@ coverage-html: coverage-report ## Generate HTML report for the code coverage coverage-browse-report: coverage-html ## Open the HTML report in the browser sensible-browser htmlcov/index.html -###### Deployment +###### Continuous integration tasks bundle: ## Bundle the tutor package in a single "dist/tutor" executable pyinstaller tutor.spec +bootstrap-dev: ## Install dev requirements + pip install . + pip install -r requirements/dev.txt -changelog-entry: ## Create a new changelog entry - scriv create - -changelog: ## Collect changelog entries in the CHANGELOG.md file - scriv collect - -release-description: ## Write the current release description to a file - @sed "s/TUTOR_VERSION/v$(shell make version)/g" docs/_release_description.md - @git log -1 --pretty=format:%b - -###### Continuous integration tasks +bootstrap-dev-plugins: bootstrap-dev ## Install dev requirements and all supported plugins + pip install -r requirements/plugins.txt pull-base-images: # Manually pull base images docker image pull docker.io/ubuntu:20.04 diff --git a/changelog.d/scriv.ini b/changelog.d/scriv.ini index 9236140..6333f3a 100644 --- a/changelog.d/scriv.ini +++ b/changelog.d/scriv.ini @@ -3,5 +3,6 @@ version = literal: tutor/__about__.py: __version__ categories = format = md md_header_level = 2 -new_fragment_template = file: scriv/new_fragment.${config:format}.j2 -entry_title_template = file: scriv/entry_title.${config:format}.j2 +new_fragment_template = file: changelog.d/scriv/new_fragment.${config:format}.j2 +entry_title_template = file: changelog.d/scriv/entry_title.${config:format}.j2 +ghrel_template = file: changelog.d/scriv/github_release.${config:format}.j2 diff --git a/docs/_release_description.md b/changelog.d/scriv/github_release.md.j2 similarity index 73% rename from docs/_release_description.md rename to changelog.d/scriv/github_release.md.j2 index 0cf51b6..9f07e98 100644 --- a/docs/_release_description.md +++ b/changelog.d/scriv/github_release.md.j2 @@ -1,13 +1,14 @@ Install this version from pip with: - pip install "tutor[full]==TUTOR_VERSION" + pip install "tutor[full]=={{ version }}" Or download the compiled binaries: - sudo curl -L "https://github.com/overhangio/tutor/releases/download/TUTOR_VERSION/tutor-$(uname -s)_$(uname -m)" -o /usr/local/bin/tutor + sudo curl -L "https://github.com/overhangio/tutor/releases/download/{{ version }}/tutor-$(uname -s)_$(uname -m)" -o /usr/local/bin/tutor sudo chmod 0755 /usr/local/bin/tutor See the [installation docs](https://docs.tutor.overhang.io/install.html) for more installation options and instructions. ## Changes +{{ body }} diff --git a/requirements/base.txt b/requirements/base.txt index c389db1..9a0c9df 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,6 +1,6 @@ # -# This file is autogenerated by pip-compile with python 3.10 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: # # pip-compile requirements/base.in # @@ -62,7 +62,9 @@ six==1.16.0 tomli==2.0.1 # via mypy typing-extensions==4.4.0 - # via mypy + # via + # -r requirements/base.in + # mypy urllib3==1.26.13 # via # kubernetes diff --git a/requirements/dev.txt b/requirements/dev.txt index 586daf3..0cafd87 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,6 +1,6 @@ # -# This file is autogenerated by pip-compile with python 3.10 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: # # pip-compile requirements/dev.in # @@ -172,7 +172,7 @@ rsa==4.9 # via # -r requirements/base.txt # google-auth -scriv==1.0.0 +scriv==1.1.0 # via -r requirements/dev.in secretstorage==3.3.3 # via keyring @@ -204,7 +204,11 @@ types-setuptools==65.6.0.2 typing-extensions==4.4.0 # via # -r requirements/base.txt + # astroid + # black # mypy + # pylint + # rich urllib3==1.26.13 # via # -r requirements/base.txt diff --git a/requirements/docs.txt b/requirements/docs.txt index 0b4da19..afd1b36 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -1,6 +1,6 @@ # -# This file is autogenerated by pip-compile with python 3.10 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: # # pip-compile requirements/docs.in # @@ -42,6 +42,8 @@ idna==3.4 # requests imagesize==1.4.1 # via sphinx +importlib-metadata==6.0.0 + # via sphinx jinja2==3.1.2 # via # -r requirements/base.txt @@ -147,6 +149,8 @@ websocket-client==1.4.2 # via # -r requirements/base.txt # kubernetes +zipp==3.11.0 + # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: # setuptools