From 029de06a9a2a2bc905f81966d2ec946e07bf27df Mon Sep 17 00:00:00 2001 From: maxim-lixakov Date: Fri, 16 Feb 2024 08:49:46 +0300 Subject: [PATCH] [DOP-13156] - add changelog to github release --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++++++++ CONTRIBUTING.rst | 6 +---- docs/conf.py | 4 +++ requirements-docs.txt | 1 + 4 files changed, 52 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b9b6205..62ec316 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,6 +55,51 @@ jobs: - name: Publish package uses: pypa/gh-action-pypi-publish@release/v1 + - name: Get changelog + run: | + cat docs/changelog/$GITHUB_REF_NAME.rst > changelog.rst + + - name: Prepare rST syntax for conversion to Markdown + run: | + # Replace Github links from Sphinx syntax with Markdown + sed -i -E 's/:github:issue:`(.*)`/#\1/g' changelog.rst + sed -i -E 's/:github:pull:`(.*)`/#\1/g' changelog.rst + sed -i -E 's/:github:user:`(.*)`/@\1/g' changelog.rst + sed -i -E 's/:github:org:`(.*)`/@\1/g' changelog.rst + + - name: Convert rST to Markdown + uses: docker://pandoc/core:2.9 + with: + args: >- + --output=changelog.md + --from=rst + --to=gfm + --wrap=none + changelog.rst + + - name: Fixing Markdown syntax after conversion + run: | + # Replace ``` {.python caption="abc"} with ```python caption="abc" + sed -i -E 's/``` \{\.(.*)\}/```\1/g' changelog.md + + # Replace ``` python with ```python + sed -i -E 's/``` (\w+)/```\1/g' changelog.md + + # Replace \# with # + sed -i -E 's/\\#/#/g' changelog.md + + - name: Get release name + id: release-name + run: | + # Release name looks like: 0.7.0 (2023-05-15) + echo -n name= > "$GITHUB_OUTPUT" + cat changelog.md | head -1 | sed -E "s/#+\s*//g" >> "$GITHUB_OUTPUT" + + - name: Fix headers + run: | + # Remove header with release name + sed -i -e '1,2d' changelog.md + - name: Create Github release id: create_release uses: softprops/action-gh-release@v1 @@ -63,5 +108,6 @@ jobs: draft: false prerelease: false name: ${{ steps.release-name.outputs.name }} + body_path: changelog.md files: | dist/* diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 6043be1..92e26b4 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -178,15 +178,11 @@ Before making a release from the ``develop`` branch, follow these steps: 4. Remove content above the version number heading in the ``${VERSION}.rst`` file -.. code:: bash - - sed -i '' "0,/^.*towncrier release notes start/d" "docs/changelog/${VERSION}.rst" - 5. Update Changelog Index .. code:: bash - sed -i '' -E "s/DRAFT/DRAFT\n ${VERSION}/" "docs/changelog/index.rst" + awk -v version=${VERSION} '/DRAFT/{print;print " " version;next}1' docs/changelog/index.rst > temp && mv temp docs/changelog/index.rst 6. Restore ``NEXT_RELEASE.rst`` file from backup diff --git a/docs/conf.py b/docs/conf.py index 4b6a4ba..cb63b7e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -51,6 +51,7 @@ "sphinx.ext.autodoc", "sphinxcontrib.autodoc_pydantic", "sphinx_favicon", + "sphinx_toolbox.github", "sphinxcontrib.towncrier", # provides `towncrier-draft-entries` directive ] numpydoc_show_class_members = True @@ -108,3 +109,6 @@ towncrier_draft_autoversion_mode = "draft" towncrier_draft_include_empty = False towncrier_draft_working_directory = PROJECT_ROOT_DIR + +github_username = "MobileTeleSystems" +github_repository = "horizon-hwm-store" diff --git a/requirements-docs.txt b/requirements-docs.txt index 9af1c34..9bcb312 100644 --- a/requirements-docs.txt +++ b/requirements-docs.txt @@ -3,5 +3,6 @@ furo numpydoc sphinx sphinx-favicon +sphinx-toolbox sphinxcontrib-towncrier towncrier