Skip to content

Commit 80751b6

Browse files
committed
Always use GitHub-CLI for public release to GitHub.
Remove 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'. To accomodate for that change: (1) GitHub-CLI (`gh`) is moved from ODKFull to ODKLite; (2) conversely, PyGithub (which was only used for the `github_python` method) is moved from ODKLite to ODKFull (it is not completely *removed*, since people may have custom workflows that depend on it). closes #1296
1 parent 33458e8 commit 80751b6

File tree

6 files changed

+27
-148
lines changed

6 files changed

+27
-148
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-i
3636
libbusiness-isbn-perl \
3737
pkg-config \
3838
xlsx2csv \
39-
gh \
4039
nodejs \
4140
npm \
4241
graphviz \

docker/odklite/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ RUN apt-get update && \
3636
rsync \
3737
time \
3838
sudo \
39-
sqlite3
39+
sqlite3 \
40+
gh
4041

4142
# Install Python environment (copied over from the builder image).
4243
COPY --from=obolibrary/odkbuild:latest /staging/lite /
@@ -107,7 +108,7 @@ RUN sed -i s/@@ODK_IMAGE_VERSION@@/$ODK_VERSION/ /tools/odk-info
107108
COPY --chmod=755 scripts/update_repo.sh /tools/update_repo
108109

109110
# Install the ODK itself.
110-
COPY --chmod=755 odk/make-release-assets.py odk/odk.py /tools
111+
COPY --chmod=755 odk/odk.py /tools
111112
COPY template/ /tools/templates/
112113
CMD python3 /tools/odk.py
113114
COPY resources/obo.epm.json /tools

odk/make-release-assets.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

odk/odk.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -765,8 +765,8 @@ class OntologyProject(JsonSchemaMixin):
765765
use_context: bool = False
766766
"""If True, a context file is created that allows the user to specify prefixes used across the project."""
767767

768-
public_release : str = "none"
769-
"""if true add functions to run automated releases (experimental). Current options are: github_curl, github_python."""
768+
public_release : Optional[str] = None
769+
"""Add supports for automatically pushing releases to the hosting service. Currently the only supported option is 'github'."""
770770

771771
public_release_assets : Optional[List[str]] = None
772772
"""A list of files that gets added to a github/gitlab/etc release (as assets). If this option is not set (None), the standard ODK assets will be deployed."""
@@ -909,6 +909,10 @@ def fill_missing(self):
909909
self.robot.obo_format_options += ' '
910910
self.robot.obo_format_options += '--clean-obo "strict drop-untranslatable-axioms"'
911911

912+
# Backwards compatibility support for deprecated 'public_release' settings
913+
if self.public_release == 'github_curl' or self.public_release == 'github_python':
914+
self.public_release = 'github'
915+
912916
@dataclass
913917
class ExecutionContext(JsonSchemaMixin):
914918
"""

requirements.txt.lite

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ dataclasses-jsonschema
66
jinja2
77
jsonpath_rw
88
jsonschema
9-
PyGithub
109
pyyaml
1110
ruamel.yaml
1211
dosdp

template/src/ontology/Makefile.jinja2

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

1510-
{%- if project.public_release != 'none' %}
1510+
{% if project.public_release == 'github' -%}
15111511
# ----------------------------------------
1512-
# GitHub release (HIGHLY experimental)
1512+
# GitHub release
15131513
# ----------------------------------------
15141514

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

15581517
.PHONY: public_release
15591518
public_release:
1560-
ls -alt $(ASSETS)
1561-
$(GITHUB_RELEASE_PYTHON) --release $(TAGNAME) $(RELEASEFILES)
1562-
{% else %}
1519+
@echo "Pushing public release $(GHVERSION)..."
1520+
@ls -alt $(RELEASE_ASSETS_AFTER_RELEASE)
1521+
@gh release create $(GHVERSION) \
1522+
--title "$(VERSION) Release" \
1523+
--generate-notes \
1524+
$(RELEASE_ASSETS_AFTER_RELEASE)
15631525

1564-
GHVERSION=v$(VERSION)
1526+
{% else -%}
1527+
# ----------------------------------------
1528+
# Public release
1529+
# ----------------------------------------
15651530

15661531
.PHONY: public_release
15671532
public_release:
1568-
@test $(GHVERSION)
1569-
ls -alt $(RELEASE_ASSETS_AFTER_RELEASE)
1570-
gh release create $(GHVERSION) --title "$(VERSION) Release" --draft $(RELEASE_ASSETS_AFTER_RELEASE) --generate-notes
1533+
@echo "ERROR: No release management system configured (or system unsupported)."
1534+
@echo " Fix your configuration or override this target with a custom"
1535+
@echo " public release workflow in {{ project.id }}.Makefile."
1536+
@false
15711537

1572-
{%- endif %}
1538+
{% endif -%}
15731539

15741540
# ----------------------------------------
15751541
# General Validation

0 commit comments

Comments
 (0)