Skip to content

Commit f3f1e7d

Browse files
committed
Always use GitHub-CLI for public releases to GitHub.
This commit removes the `github_curl` and `github_python` methods of pushing a release to GitHub – these should no longer be needed now that GitHub-CLI is available. The public_release ODK option should now be set to the name of the hosting service for releases. For now, the only supported option is `github` (which, in effect, is exactly as before). The older values `github_curl` and `github_python` are silently transformed into `github`. This is a backport of INCATools/ontology-development-kit#1297, which happened in the original repository after ODK-Core had been started.
1 parent 506a89a commit f3f1e7d

File tree

2 files changed

+30
-56
lines changed

2 files changed

+30
-56
lines changed

src/incatools/odk/model.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,11 +1009,12 @@ class OntologyProject(JsonSchemaMixin):
10091009
use_context: bool = False
10101010
"""Uses a context file to manage prefixes used across the project."""
10111011

1012-
public_release: str = "none"
1013-
"""If true add targets to run automated releases.
1012+
public_release: Optional[str] = None
1013+
"""Add supports for automatically publishing releases.
10141014
1015-
This is experimental. Current options: github_curl, github_python.
1016-
"""
1015+
The value should be the name of the hosting service where the
1016+
releases should be pushed. Currently the only supported option is
1017+
'github'."""
10171018

10181019
public_release_assets: Optional[List[str]] = None
10191020
"""Files to deploy as release assets.
@@ -1192,3 +1193,10 @@ def derive_fields(self) -> None:
11921193
self.robot.obo_format_options += (
11931194
'--clean-obo "strict drop-untranslatable-axioms"'
11941195
)
1196+
1197+
# Backwards compatibility support for deprecated 'public_release' settings
1198+
if (
1199+
self.public_release == "github_curl"
1200+
or self.public_release == "github_python"
1201+
):
1202+
self.public_release = "github"

src/incatools/odk/templates/src/ontology/Makefile.jinja2

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,69 +1503,35 @@ $(ONT)-basic.owl: $(EDIT_PREPROCESSED) $(OTHER_SRC) $(SIMPLESEED) $(KEEPRELATION
15031503
explain_unsat: $(EDIT_PREPROCESSED)
15041504
$(ROBOT) explain -i $< -M unsatisfiability --unsatisfiable random:10 --explanation $(TMPDIR)/[email protected]
15051505

1506-
{%- if project.public_release != 'none' %}
1506+
{% if project.public_release == 'github' -%}
15071507
# ----------------------------------------
1508-
# GitHub release (HIGHLY experimental)
1508+
# GitHub release
15091509
# ----------------------------------------
15101510

1511-
RELEASEFILES={% if project.public_release_assets is not none -%}{% for gha in project.public_release_assets %} {{ gha }}{% endfor -%}{% else -%}$(ASSETS){% endif %}
1512-
TAGNAME=v$(TODAY)
1513-
{% endif %}
1514-
1515-
{% if project.public_release == 'github_curl' %}
1516-
USER=unknown
1517-
GH_ASSETS = $(patsubst %, $(TMPDIR)/gh_release_asset_%.txt, $(RELEASEFILES))
1518-
GITHUB_REPO={{ project.github_org }}/{{ project.repo }}
1519-
1520-
$(TMPDIR)/release_get.txt: | $(TMPDIR)
1521-
curl -s https://api.github.com/repos/${GITHUB_REPO}/releases/tags/${TAGNAME} > $@
1522-
1523-
$(TMPDIR)/release_op.txt: $(TMPDIR)/release_get.txt | $(TMPDIR)
1524-
$(eval RELEASEID=$(shell cat $(TMPDIR)/release_get.txt | jq '.id'))
1525-
if ! [ "$(RELEASEID)" -eq "$(RELEASEID)" ] ; then \
1526-
curl -s -X POST \
1527-
https://api.github.com/repos/${GITHUB_REPO}/releases \
1528-
-H 'Accept: */*' \
1529-
-H 'Content-Type: application/json' \
1530-
-u ${USER} \
1531-
-d '{ "tag_name": "${TAGNAME}", "target_commitish": "master", "name": "${TAGNAME}", "body": "Ontology release ${TODAY}", "draft": false, "prerelease": false }' > $@; \
1532-
else \
1533-
cp $< $@; \
1534-
fi;
1535-
1536-
$(TMPDIR)/gh_release_id.txt: $(TMPDIR)/release_op.txt | $(TMPDIR)
1537-
echo $(shell cat $(TMPDIR)/release_op.txt | jq '.id') > $@;
1538-
1539-
$(TMPDIR)/gh_release_asset_%.txt: $(TMPDIR)/gh_release_id.txt % | $(TMPDIR)
1540-
curl -X POST \
1541-
"https://uploads.github.com/repos/${GITHUB_REPO}/releases/$(shell cat $(TMPDIR)/gh_release_id.txt)/assets?name=$*&label=$*" \
1542-
--data-binary @$* \
1543-
-u ${USER} \
1544-
-H 'Accept: */*' \
1545-
-H 'Cache-Control: no-cache' \
1546-
-H 'Connection: keep-alive' \
1547-
-H 'Content-Type: application/octet-stream' > $@
1548-
1549-
public_release: $(TMPDIR)/gh_release_id.txt $(GH_ASSETS) | $(TMPDIR)
1550-
{% endif %}
1551-
{%- if project.public_release == 'github_python' %}
1552-
GITHUB_RELEASE_PYTHON=make-release-assets.py
1511+
GHVERSION = v$(VERSION)
15531512

15541513
.PHONY: public_release
15551514
public_release:
1556-
ls -alt $(ASSETS)
1557-
$(GITHUB_RELEASE_PYTHON) --release $(TAGNAME) $(RELEASEFILES)
1558-
{% else %}
1515+
@echo "Pushing public release $(GHVERSION)..."
1516+
@ls -alt $(RELEASE_ASSETS_AFTER_RELEASE)
1517+
@gh release create $(GHVERSION) \
1518+
--title "$(VERSION) Release" \
1519+
--generate-notes \
1520+
$(RELEASE_ASSETS_AFTER_RELEASE)
15591521

1560-
GHVERSION=v$(VERSION)
1522+
{% else -%}
1523+
# ----------------------------------------
1524+
# Public release
1525+
# ----------------------------------------
15611526

15621527
.PHONY: public_release
15631528
public_release:
1564-
@test $(GHVERSION)
1565-
ls -alt $(RELEASE_ASSETS_AFTER_RELEASE)
1566-
gh release create $(GHVERSION) --title "$(VERSION) Release" --draft $(RELEASE_ASSETS_AFTER_RELEASE) --generate-notes
1529+
@echo "ERROR: No release management system configured (or system unsupported)."
1530+
@echo " Fix your configuration or override this target with a custom"
1531+
@echo " public release workflow in {{ project.id }}.Makefile."
1532+
@false
15671533

1568-
{%- endif %}
1534+
{% endif -%}
15691535

15701536
# ----------------------------------------
15711537
# General Validation

0 commit comments

Comments
 (0)