Skip to content

Commit f5a3c4f

Browse files
committed
Improved github release commands
1 parent c62a466 commit f5a3c4f

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

Makefile

+31-9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ AUTHOR:=$(shell grep "MyName =" patoolib/configuration.py | cut -d '"' -f2)
2121
APPNAME:=$(shell grep "AppName =" patoolib/configuration.py | cut -d '"' -f2)
2222
ARCHIVE_SOURCE:=$(APPNAME)-$(VERSION).tar.gz
2323
ARCHIVE_WHEEL:=$(APPNAME)-$(VERSION)-py2.py3-none-any.whl
24+
GITRELEASETAG:=$(VERSION)
2425
GITUSER:=wummel
2526
GITREPO:=$(APPNAME)
2627
HOMEPAGE:=$(HOME)/public_html/patool-webpage.git
@@ -87,23 +88,37 @@ upload: ## upload a new release to pypi
8788
twine upload --config-file $(XDG_CONFIG_HOME)/pypirc \
8889
dist/$(ARCHIVE_SOURCE) dist/$(ARCHIVE_WHEEL)
8990

90-
.PHONY: hub
91-
hub: ## add and push a github release
91+
# export GITHUB_TOKEN for the hub command
92+
# Generate a fine grained access token with:
93+
# - Restricted to this repository (patool)
94+
# - Repository permission: Metadata -> Read (displayed as "Read access to metadata" in token view)
95+
# - Repository permission: Contents -> Read and write (displayed as "Read and Write access to code" in token view)
96+
# - Expiration in 90 days
97+
# After token generation or renewal, copy the contents in the local .envrc file and run "direnv allow ."
98+
.PHONY: hub hub-draft hub-publish
99+
hub: hub-draft hub-publish ## make a github release
100+
hub-draft: ## create a draft release
92101
hub release create \
93-
-a dist/$(ARCHIVE_SOURCE) \
94-
-a dist/$(ARCHIVE_WHEEL) \
95-
-m "Release $(VERSION)" \
96-
upstream/$(VERSION)
102+
--draft \
103+
--attach dist/$(ARCHIVE_SOURCE) \
104+
--message "Release $(GITRELEASETAG)" \
105+
"$(GITRELEASETAG)"
106+
hub-publish: ## add the wheel file and publish the draft
107+
hub release edit \
108+
--draft=false \
109+
--attach dist/$(ARCHIVE_WHEEL) \
110+
--message "" \
111+
"$(GITRELEASETAG)"
97112

98113
# Make a new release by calling all the distinct steps in the correct order.
99114
# Each step is a separate target so that it's easy to do this manually if
100115
# anything screwed up.
101116
.PHONY: release
102117
release: distclean releasecheck ## release a new version of patool
103-
$(MAKE) dist hub upload homepage github-issues
118+
$(MAKE) dist tag hub upload homepage github-issues
104119

105120
.PHONY: releasecheck
106-
releasecheck: checkgit checkchangelog lint test ## check that repo is ready for release
121+
releasecheck: checkgit checkgitreleasetag checkchangelog lint test ## check that repo is ready for release
107122

108123
.PHONY: checkgit
109124
checkgit: ## check that git changes are all committed on the main branch
@@ -120,11 +135,18 @@ checkgit: ## check that git changes are all committed on the main branch
120135
false; \
121136
fi
122137

138+
.PHONY: checkgitreleasetag
139+
checkgitreleasetag: ## check release tag for git exists
140+
@if [ -z "$(shell git tag -l -- $(GITRELEASETAG))" ]; then \
141+
echo "ERROR: git tag \"$(GITRELEASETAG)\" does not exist, execute 'git tag -a $(GITRELEASETAG) -m \"$(GITRELEASETAG)\"'"; \
142+
false; \
143+
fi
144+
123145
.PHONY: github-issues
124146
github-issues: ## close github issues mentioned in changelog
125147
# github-changelog is a local tool which parses the changelog and automatically
126148
# closes issues mentioned in the changelog entries.
127-
cd .. && github-changelog $(DRYRUN) $(GITUSER) $(GITREPO) patool.git/doc/changelog.txt
149+
cd .. && github-changelog $(GITUSER) $(GITREPO) patool.git/doc/changelog.txt
128150

129151

130152
############ Versioning ############

0 commit comments

Comments
 (0)