From f8cb884724eb030ae9cbcc701e181ba01e03b683 Mon Sep 17 00:00:00 2001 From: Nick Irvine <nick@segment.com> Date: Mon, 22 Apr 2019 17:27:43 -0700 Subject: [PATCH] fix: idempotent publishes (#145) So we can rebuild in the face of temporary failure --- Makefile.release | 28 +++++++++++++++++++++++++--- vendor/vendor.json | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Makefile.release b/Makefile.release index 326eaa62..7bb79cbc 100644 --- a/Makefile.release +++ b/Makefile.release @@ -5,12 +5,18 @@ include Makefile +# use bash so we can use set -o pipefail +SHELL := /bin/bash + # set --pre-release if not tagged or tree is dirty or there's a `-` in the tag ifneq (,$(findstring -,$(VERSION))) GITHUB_RELEASE_FLAGS := "--pre-release" PACKAGECLOUD_NAME_SUFFIX := "-prerelease" endif +# TODO: use this consistently; 99% of the time, we don't want a v +VERSION_NO_V := $(patsubst v%,%,$(VERSION)) + PACKAGECLOUD_DEB_DISTROS := \ debian/stretch \ ubuntu/trusty \ @@ -41,7 +47,12 @@ github-release: --repo aws-okta \ $(GITHUB_RELEASE_FLAGS) \ --tag $(VERSION) \ - --name $(VERSION) + --name $(VERSION) || \ + github-release info \ + --security-token $$GH_LOGIN \ + --user segmentio \ + --repo aws-okta \ + --tag $(VERSION) publish-github-darwin-bin: dist/aws-okta-$(VERSION)-darwin-amd64 | github-release github-release upload \ @@ -50,6 +61,7 @@ publish-github-darwin-bin: dist/aws-okta-$(VERSION)-darwin-amd64 | github-releas --repo aws-okta \ --tag $(VERSION) \ --name aws-okta-$(VERSION)-darwin-amd64 \ + --replace \ --file $< publish-github-linux-bin: dist/aws-okta-$(VERSION)-linux-amd64 | github-release @@ -59,6 +71,7 @@ publish-github-linux-bin: dist/aws-okta-$(VERSION)-linux-amd64 | github-release --repo aws-okta \ --tag $(VERSION) \ --name aws-okta-$(VERSION)-linux-amd64 \ + --replace \ --file $< publish-github-deb: dist/aws-okta_$(VERSION)_amd64.deb | github-release @@ -68,6 +81,7 @@ publish-github-deb: dist/aws-okta_$(VERSION)_amd64.deb | github-release --repo aws-okta \ --tag $(VERSION) \ --name aws-okta_$(VERSION)_amd64.deb \ + --replace \ --file $< publish-github-rpm: dist/aws-okta_$(VERSION)_amd64.rpm | github-release @@ -77,6 +91,7 @@ publish-github-rpm: dist/aws-okta_$(VERSION)_amd64.rpm | github-release --repo aws-okta \ --tag $(VERSION) \ --name aws-okta_$(VERSION)_amd64.rpm \ + --replace \ --file $< publish-github-sha256sums: dist/aws-okta-$(VERSION).sha256sums | github-release @@ -86,6 +101,7 @@ publish-github-sha256sums: dist/aws-okta-$(VERSION).sha256sums | github-release --repo aws-okta \ --tag $(VERSION) \ --name aws-okta-$(VERSION).sha256sums \ + --replace \ --file dist/aws-okta-$(VERSION).sha256sums packagecloud.conf.json: @@ -95,13 +111,19 @@ packagecloud.conf.json: # so we attempt to filter that out publish-packagecloud-deb: dist/aws-okta_$(VERSION)_amd64.deb packagecloud.conf.json - @for v in $(PACKAGECLOUD_DEB_DISTROS); do \ + @set -o pipefail; \ + for v in $(PACKAGECLOUD_DEB_DISTROS); do \ + (package_cloud yank --config packagecloud.conf.json segment/aws-okta$(PACKAGECLOUD_NAME_SUFFIX)/$$v aws-okta_$(VERSION_NO_V)_amd64.deb || true) | \ + grep -v 'with token:' || true ; \ package_cloud push --config packagecloud.conf.json segment/aws-okta$(PACKAGECLOUD_NAME_SUFFIX)/$$v $< | \ grep -v 'with token:' ; \ done publish-packagecloud-rpm: dist/aws-okta_$(VERSION)_amd64.rpm packagecloud.conf.json - @for v in $(PACKAGECLOUD_RPM_DISTROS); do \ + @set -o pipefail; \ + for v in $(PACKAGECLOUD_RPM_DISTROS); do \ + (package_cloud yank --config packagecloud.conf.json segment/aws-okta$(PACKAGECLOUD_NAME_SUFFIX)/$$v aws-okta-$(subst -,_,$(VERSION_NO_V))-1.x86_64.rpm || true) | \ + grep -v 'with token:' || true ; \ package_cloud push --config packagecloud.conf.json segment/aws-okta$(PACKAGECLOUD_NAME_SUFFIX)/$$v $< | \ grep -v 'with token:' ; \ done diff --git a/vendor/vendor.json b/vendor/vendor.json index dc6072a7..592de606 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -289,7 +289,7 @@ "revisionTime": "2016-04-24T05:23:52Z" }, { - "checksumSHA1": "DYv6Q1+VfnUVxMwvk5IshAClLvw=", + "checksumSHA1": "x/C9sWJ33glBGKgGvb8VvUQvR8s=", "path": "github.com/sirupsen/logrus", "revision": "5e5dc898656f695e2a086b8e12559febbfc01562", "revisionTime": "2017-05-15T10:45:16Z"