Skip to content

Commit

Permalink
[DOP-13156] - add changelog to github release
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-lixakov committed Feb 16, 2024
1 parent 83851f0 commit 029de06
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -63,5 +108,6 @@ jobs:
draft: false
prerelease: false
name: ${{ steps.release-name.outputs.name }}
body_path: changelog.md
files: |
dist/*
6 changes: 1 addition & 5 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
1 change: 1 addition & 0 deletions requirements-docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ furo
numpydoc
sphinx
sphinx-favicon
sphinx-toolbox
sphinxcontrib-towncrier
towncrier

0 comments on commit 029de06

Please sign in to comment.