Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix parsing of changes as HTML for Zenodo release #777

Merged
merged 6 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/zenodo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
run: |
make generate-changes-html VERSION=${{ github.ref_name }} || true
echo "ZENODO_DESCRIPTION=$(cat ${{ env.CHANGES_HTML }} | tr -d '\n' || echo '')" >> $GITHUB_ENV
cat ${{ env.CHANGES_HTML }}

- name: Run Zenodo Publish
id: deploy_zenodo
Expand Down
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -754,29 +754,37 @@ bump: ## bump version using VERSION specified as user input [make VERSION=<x.y.
@-bash -c '$(CONDA_CMD) bump2version $(BUMP_XARGS) --new-version "${VERSION}" patch;'

.PHONY: extract-changes
extract-changes: ## uses the specified VERSION to extract its sub-section in CHANGES.rst
extract-changes: mkdir-reports ## uses the specified VERSION to extract its sub-section in CHANGES.rst
@[ "${VERSION}" ] || ( echo ">> 'VERSION' is not set. It is required to extract changes."; exit 1 )
@-echo "Extracting changes for ${VERSION} ..."
@bash -c '\
bash -c '\
START=$$(cat "$(APP_ROOT)/CHANGES.rst" | grep -n "crim-ca/weaver/tree/${VERSION}" | cut -d ":" -f 1); \
STOP=$$(tail -n +$$(($${START:-0} + 2)) "$(APP_ROOT)/CHANGES.rst" \
| grep -n ".. _changes" \
| cut -d ":" -f 1 | head -n 1); \
tail -n +$${START:-0} "$(APP_ROOT)/CHANGES.rst" | head -n $${STOP:--1} \
> "$(REPORTS_DIR)/CHANGES_${VERSION}.rst" \
'
@-echo "Generated changes: $(REPORTS_DIR)/CHANGES_${VERSION}.rst"

# note:
# some text must be inserted before and between the first 'version heading' and the 'changes' sub-heading
# otherwise headers levels are not parsed correctly (they are considered sections all using H1)
# therefore, inject the contents needed to parse as desired, and remove the temp HTML content afterwards
.PHONY: generate-changes-html
generate-changes-html: extract-changes ## extract CHANGES.rst section as HTML using the specified VERSION
@[ "${VERSION}" ] || ( echo ">> 'VERSION' is not set. It is required to extract changes."; exit 1 )
@-echo "Checking necessary Sphinx dependency ..."
@pip show sphinx >/dev/null || bash -c '$(CONDA_CMD) $(MAKE) -C "$(APP_ROOT)" install-doc'
@-echo "Checking necessary documentation dependency ..."
@which rst2html >/dev/null || pip install docutils
@-echo "Converting changes for ${VERSION} ..."
@echo '%(body)s' > "$(REPORTS_DIR)/html-body-template.txt"
@sed -i -e 's|Changes:|\\ \n\nChanges:|' "$(REPORTS_DIR)/CHANGES_${VERSION}.rst"
@sed -i -e "s|^\`${VERSION}| \n###\n\n\\ \n\n\`${VERSION}|" "$(REPORTS_DIR)/CHANGES_${VERSION}.rst"
@rst2html \
--template "$(REPORTS_DIR)/html-body-template.txt" \
"$(REPORTS_DIR)/CHANGES_${VERSION}.rst" "$(REPORTS_DIR)/CHANGES_${VERSION}.html"
@-echo "Generates changes: $(REPORTS_DIR)/CHANGES_${VERSION}.html"
@sed -i -e 's|<p>###</p>||' "$(REPORTS_DIR)/CHANGES_${VERSION}.html"
@-echo "Generated changes: $(REPORTS_DIR)/CHANGES_${VERSION}.html"

.PHONY: generate-archive
generate-archive: ## generate ZIP and TAR.GZ archives using current contents
Expand All @@ -789,6 +797,7 @@ generate-archive: ## generate ZIP and TAR.GZ archives using current contents
--exclude-vcs-ignores \
--exclude=*.zip \
--exclude=*.tar.gz \
--exclude="$(APP_NAME)-$(APP_VERSION).tar.gz" \
-cvzf "$(APP_NAME)-$(APP_VERSION).tar.gz" \
--transform 's,^\.,$(APP_NAME)-$(APP_VERSION),' \
.
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ for each process.
:target: https://app.fossa.com/projects/git%2Bgithub.com%2Fcrim-ca%2Fweaver?ref=badge_shield&issueType=license
:alt: FOSSA Status

.. |citation-zenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.14210718.svg
.. |citation-zenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.14210717.svg
:alt: Zenodo DOI
:target: https://zenodo.org/doi/10.5281/zenodo.14210718
:target: https://zenodo.org/doi/10.5281/zenodo.14210717

.. |citation-cff| image:: https://img.shields.io/badge/citation-cff-blue
:alt: CFF
Expand Down
Loading