From 5cd51d1c77308431dee4e3450f6c20f27c05c39e Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Fri, 20 Dec 2019 11:26:38 +0100 Subject: [PATCH 1/5] Don't pack sources (github does it better), sign sources --- .circleci/config.yml | 6 ------ Makefile | 15 ++++++--------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 81c6c7b60..7131bacd5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,16 +64,10 @@ jobs: # Clean up rm -rf ./.git rm -rf ./dist/* - # Pack source - cd .. - tar -czf ${CIRCLE_PROJECT_REPONAME}-${CIRCLE_TAG}.tar.gz ${CIRCLE_PROJECT_REPONAME} - cd ${CIRCLE_PROJECT_REPONAME} # Use latest installed python3 from pyenv export PYENV_VERSION="$(pyenv versions | grep -Po '\b3\.\d+\.\d+' | tail -1)" pip install packagecore packagecore -c misc/packagecore/packagecore.yaml -o ./dist/ ${CIRCLE_TAG#v} - # Move source pack to dist - mv ../${CIRCLE_PROJECT_REPONAME}-${CIRCLE_TAG}.tar.gz dist/ - run: name: "publish to GitHub" diff --git a/Makefile b/Makefile index 43287f812..f7d7c13ca 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,6 @@ CFLAGS += $(CFLAGS_CURSES) LDLIBS += $(LDLIBS_CURSES) -DISTFILES = src nnn.1 Makefile README.md LICENSE SRC = src/nnn.c HEADERS = src/nnn.h BIN = nnn @@ -85,16 +84,14 @@ uninstall: strip: $(BIN) $(STRIP) $^ -dist: - mkdir -p nnn-$(VERSION) - $(CP) -r $(DISTFILES) nnn-$(VERSION) - tar -cf nnn-$(VERSION).tar nnn-$(VERSION) - gzip nnn-$(VERSION).tar - $(RM) -r nnn-$(VERSION) +sign: + git archive -o nnn-$(VERSION).tar.gz --format tar.gz --prefix=nnn-$(VERSION)/ v$(VERSION) + gpg --detach-sign nnn-$(VERSION).tar.gz + rm -f nnn-$(VERSION).tar.gz clean: - $(RM) -f $(BIN) nnn-$(VERSION).tar.gz + $(RM) -f $(BIN) *.sig skip: ; -.PHONY: all debug install uninstall strip dist clean +.PHONY: all debug install uninstall strip sign clean From d59d257af277bac76c84bbbb7d43bce4dec0c2d0 Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Fri, 20 Dec 2019 12:09:13 +0100 Subject: [PATCH 2/5] Make CircleCI generate the same git archive as Github, return make dist --- .circleci/config.yml | 4 ++++ Makefile | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7131bacd5..d50b1999c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,10 +64,14 @@ jobs: # Clean up rm -rf ./.git rm -rf ./dist/* + # Pack source + git archive -o ../${CIRCLE_PROJECT_REPONAME}-${CIRCLE_TAG}.tar.gz --format tar.gz --prefix=${CIRCLE_PROJECT_REPONAME}-${CIRCLE_TAG#v}/ ${CIRCLE_TAG} # Use latest installed python3 from pyenv export PYENV_VERSION="$(pyenv versions | grep -Po '\b3\.\d+\.\d+' | tail -1)" pip install packagecore packagecore -c misc/packagecore/packagecore.yaml -o ./dist/ ${CIRCLE_TAG#v} + # Move source pack to dist + mv ../${CIRCLE_PROJECT_REPONAME}-${CIRCLE_TAG}.tar.gz dist/ - run: name: "publish to GitHub" diff --git a/Makefile b/Makefile index f7d7c13ca..639f25220 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,7 @@ CFLAGS += $(CFLAGS_CURSES) LDLIBS += $(LDLIBS_CURSES) +DISTFILES = src nnn.1 Makefile README.md LICENSE SRC = src/nnn.c HEADERS = src/nnn.h BIN = nnn @@ -84,6 +85,13 @@ uninstall: strip: $(BIN) $(STRIP) $^ +dist: + mkdir -p nnn-$(VERSION) + $(CP) -r $(DISTFILES) nnn-$(VERSION) + tar -cf nnn-$(VERSION).tar nnn-$(VERSION) + gzip nnn-$(VERSION).tar + $(RM) -r nnn-$(VERSION) + sign: git archive -o nnn-$(VERSION).tar.gz --format tar.gz --prefix=nnn-$(VERSION)/ v$(VERSION) gpg --detach-sign nnn-$(VERSION).tar.gz @@ -94,4 +102,4 @@ clean: skip: ; -.PHONY: all debug install uninstall strip sign clean +.PHONY: all debug install uninstall strip dist sign clean From cbe4001bc8df3ee4a060e9ecc0a5c7a114a28c28 Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Fri, 20 Dec 2019 12:10:27 +0100 Subject: [PATCH 3/5] Revert make clean too --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 639f25220..02ff6c0f8 100644 --- a/Makefile +++ b/Makefile @@ -98,7 +98,7 @@ sign: rm -f nnn-$(VERSION).tar.gz clean: - $(RM) -f $(BIN) *.sig + $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig skip: ; From 0ac0505ec26a0c1c7172fa9908580551d098363d Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Fri, 20 Dec 2019 13:56:00 +0100 Subject: [PATCH 4/5] Upload signature to Github release --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 02ff6c0f8..f93abc9ce 100644 --- a/Makefile +++ b/Makefile @@ -94,9 +94,14 @@ dist: sign: git archive -o nnn-$(VERSION).tar.gz --format tar.gz --prefix=nnn-$(VERSION)/ v$(VERSION) - gpg --detach-sign nnn-$(VERSION).tar.gz + gpg --detach-sign --yes nnn-$(VERSION).tar.gz rm -f nnn-$(VERSION).tar.gz + $(eval TOKEN=$(shell cat /tmp/access_token)) + $(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id)) + curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \ + -H 'Authorization: token $(TOKEN)' -H 'Content-Type: application/pgp-signature' --upload-file nnn-$(VERSION).tar.gz.sig + clean: $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig From d2a0cbbe9eb1528c4d4b6dbe19e32b7b15b81105 Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Fri, 20 Dec 2019 18:59:24 +0100 Subject: [PATCH 5/5] Read Github token from an env variable --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f93abc9ce..51dee9768 100644 --- a/Makefile +++ b/Makefile @@ -97,10 +97,10 @@ sign: gpg --detach-sign --yes nnn-$(VERSION).tar.gz rm -f nnn-$(VERSION).tar.gz - $(eval TOKEN=$(shell cat /tmp/access_token)) $(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id)) curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \ - -H 'Authorization: token $(TOKEN)' -H 'Content-Type: application/pgp-signature' --upload-file nnn-$(VERSION).tar.gz.sig + -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/pgp-signature' \ + --upload-file nnn-$(VERSION).tar.gz.sig clean: $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig