forked from segmentio/aws-okta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.release
165 lines (135 loc) · 4.97 KB
/
Makefile.release
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# Goals:
# - Linux releases can be published to Github automatically by CircleCI
#
# This Makefile is meant for machines
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 \
ubuntu/xenial \
ubuntu/bionic \
ubuntu/cosmic \
ubuntu/disco
PACKAGECLOUD_RPM_DISTROS := \
fedora/27 \
fedora/28 \
fedora/29 \
fedora/30
publish: publish-github publish-packagecloud
# note: this doesn't include sha256sums
publish-linux: publish-github-linux publish-packagecloud
publish-github: publish-github-darwin publish-github-linux publish-github-sha256sums
publish-github-darwin: publish-github-darwin-bin
publish-github-linux: publish-github-linux-bin publish-github-deb publish-github-rpm
publish-packagecloud: publish-packagecloud-deb publish-packagecloud-rpm
github-release:
github-release release \
--security-token $$GH_LOGIN \
--user segmentio \
--repo aws-okta \
$(GITHUB_RELEASE_FLAGS) \
--tag $(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 \
--security-token $$GH_LOGIN \
--user segmentio \
--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
github-release upload \
--security-token $$GH_LOGIN \
--user segmentio \
--repo aws-okta \
--tag $(VERSION) \
--name aws-okta-$(VERSION)-linux-amd64 \
--replace \
--file $<
publish-github-deb: dist/aws-okta_$(VERSION)_amd64.deb | github-release
github-release upload \
--security-token $$GH_LOGIN \
--user segmentio \
--repo aws-okta \
--tag $(VERSION) \
--name aws-okta_$(VERSION)_amd64.deb \
--replace \
--file $<
publish-github-rpm: dist/aws-okta_$(VERSION)_amd64.rpm | github-release
github-release upload \
--security-token $$GH_LOGIN \
--user segmentio \
--repo aws-okta \
--tag $(VERSION) \
--name aws-okta_$(VERSION)_amd64.rpm \
--replace \
--file $<
publish-github-sha256sums: dist/aws-okta-$(VERSION).sha256sums | github-release
github-release upload \
--security-token $$GH_LOGIN \
--user segmentio \
--repo aws-okta \
--tag $(VERSION) \
--name aws-okta-$(VERSION).sha256sums \
--replace \
--file dist/aws-okta-$(VERSION).sha256sums
packagecloud.conf.json:
@echo "{\"url\":\"https://packagecloud.io\",\"token\":\"$${PACKAGECLOUD_TOKEN}\"}" > $@
# package_cloud prints the last 4 chars of our token :(
# so we attempt to filter that out
publish-packagecloud-deb: dist/aws-okta_$(VERSION)_amd64.deb packagecloud.conf.json
@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
@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
dist: dist-darwin dist-linux dist/aws-okta-$(VERSION).sha256sums
dist-darwin: dist/aws-okta-$(VERSION)-darwin-amd64
dist-linux: dist/aws-okta-$(VERSION)-linux-amd64 dist/aws-okta_$(VERSION)_amd64.deb dist/aws-okta_$(VERSION)_amd64.rpm
dist/aws-okta-$(VERSION).sha256sums: dist/aws-okta-$(VERSION)-darwin-amd64 dist/aws-okta-$(VERSION)-linux-amd64 dist/aws-okta_$(VERSION)_amd64.deb dist/aws-okta_$(VERSION)_amd64.rpm
sha256sum $^ | sed 's|dist/||g' > $@
dist/nfpm-$(VERSION).yaml: | dist/
sed -e "s/\$${VERSION}/$(VERSION)/g" -e "s|\$${DIST_BIN}|dist/aws-okta-$(VERSION)-linux-amd64|g" < nfpm.yaml.tmpl > $@
dist/aws-okta_$(VERSION)_amd64.deb: dist/nfpm-$(VERSION).yaml dist/aws-okta-$(VERSION)-linux-amd64
nfpm -f $< pkg --target $@
dist/aws-okta_$(VERSION)_amd64.rpm: dist/nfpm-$(VERSION).yaml dist/aws-okta-$(VERSION)-linux-amd64
nfpm -f $< pkg --target $@
.PHONY: \
dist \
dist-darwin \
dist-linux \
publish \
publish-github \
publish-github-linux \
publish-github-linux-bin \
publish-github-rpm \
publish-github-deb \
publish-github-darwin \
publish-github-darwin-bin \
github-release