Rewrite dist script (#302)
* Rewrite dist scripts * add changelog entry * remove multiple loops in dist * styling
This commit is contained in:
		
							parent
							
								
									ba21c90c7a
								
							
						
					
					
						commit
						f40dab8748
					
				|  | @ -9,6 +9,7 @@ | ||||||
| - [#258](https://github.com/pusher/oauth2_proxy/pull/258) Add IDToken for Azure provider | - [#258](https://github.com/pusher/oauth2_proxy/pull/258) Add IDToken for Azure provider | ||||||
|   - This PR adds the IDToken into the session for the Azure provider allowing requests to a backend to be identified as a specific user. As a consequence, if you are using a cookie to store the session the cookie will now exceed the 4kb size limit and be split into multiple cookies. This can cause problems when using nginx as a proxy, resulting in no cookie being passed at all. Either increase the proxy_buffer_size in nginx or implement the redis session storage (see https://pusher.github.io/oauth2_proxy/configuration#redis-storage) |   - This PR adds the IDToken into the session for the Azure provider allowing requests to a backend to be identified as a specific user. As a consequence, if you are using a cookie to store the session the cookie will now exceed the 4kb size limit and be split into multiple cookies. This can cause problems when using nginx as a proxy, resulting in no cookie being passed at all. Either increase the proxy_buffer_size in nginx or implement the redis session storage (see https://pusher.github.io/oauth2_proxy/configuration#redis-storage) | ||||||
| - [#286](https://github.com/pusher/oauth2_proxy/pull/286) Requests.go updated with useful error messages (@biotom) | - [#286](https://github.com/pusher/oauth2_proxy/pull/286) Requests.go updated with useful error messages (@biotom) | ||||||
|  | - [#302](https://github.com/pusher/oauth2_proxy/pull/302) Rewrite dist script (@syscll) | ||||||
| 
 | 
 | ||||||
| # v4.0.0 | # v4.0.0 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										27
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										27
									
								
								Makefile
								
								
								
								
							|  | @ -61,29 +61,4 @@ test: lint | ||||||
| 
 | 
 | ||||||
| .PHONY: release | .PHONY: release | ||||||
| release: lint test | release: lint test | ||||||
| 	mkdir release | 	BINARY=${BINARY} VERSION=${VERSION} ./dist.sh | ||||||
| 	mkdir release/$(BINARY)-$(VERSION).darwin-amd64.$(GO_VERSION) |  | ||||||
| 	mkdir release/$(BINARY)-$(VERSION).linux-amd64.$(GO_VERSION) |  | ||||||
| 	mkdir release/$(BINARY)-$(VERSION).linux-arm64.$(GO_VERSION) |  | ||||||
| 	mkdir release/$(BINARY)-$(VERSION).linux-armv6.$(GO_VERSION) |  | ||||||
| 	mkdir release/$(BINARY)-$(VERSION).windows-amd64.$(GO_VERSION) |  | ||||||
| 	GO111MODULE=on GOOS=darwin GOARCH=amd64 go build -ldflags="-X main.VERSION=${VERSION}" \
 |  | ||||||
| 		-o release/$(BINARY)-$(VERSION).darwin-amd64.$(GO_VERSION)/$(BINARY) github.com/pusher/oauth2_proxy |  | ||||||
| 	GO111MODULE=on GOOS=linux GOARCH=amd64 go build -ldflags="-X main.VERSION=${VERSION}" \
 |  | ||||||
| 		-o release/$(BINARY)-$(VERSION).linux-amd64.$(GO_VERSION)/$(BINARY) github.com/pusher/oauth2_proxy |  | ||||||
| 	GO111MODULE=on GOOS=linux GOARCH=arm64 go build -ldflags="-X main.VERSION=${VERSION}" \
 |  | ||||||
| 		-o release/$(BINARY)-$(VERSION).linux-arm64.$(GO_VERSION)/$(BINARY) github.com/pusher/oauth2_proxy |  | ||||||
| 	GO111MODULE=on GOOS=linux GOARCH=arm GOARM=6 go build -ldflags="-X main.VERSION=${VERSION}" \
 |  | ||||||
| 		-o release/$(BINARY)-$(VERSION).linux-armv6.$(GO_VERSION)/$(BINARY) github.com/pusher/oauth2_proxy |  | ||||||
| 	GO111MODULE=on GOOS=windows GOARCH=amd64 go build -ldflags="-X main.VERSION=${VERSION}" \
 |  | ||||||
| 		-o release/$(BINARY)-$(VERSION).windows-amd64.$(GO_VERSION)/$(BINARY) github.com/pusher/oauth2_proxy |  | ||||||
| 	shasum -a 256 release/$(BINARY)-$(VERSION).darwin-amd64.$(GO_VERSION)/$(BINARY) > release/$(BINARY)-$(VERSION).darwin-amd64-sha256sum.txt |  | ||||||
| 	shasum -a 256 release/$(BINARY)-$(VERSION).linux-amd64.$(GO_VERSION)/$(BINARY) > release/$(BINARY)-$(VERSION).linux-amd64-sha256sum.txt |  | ||||||
| 	shasum -a 256 release/$(BINARY)-$(VERSION).linux-arm64.$(GO_VERSION)/$(BINARY) > release/$(BINARY)-$(VERSION).linux-arm64-sha256sum.txt |  | ||||||
| 	shasum -a 256 release/$(BINARY)-$(VERSION).linux-armv6.$(GO_VERSION)/$(BINARY) > release/$(BINARY)-$(VERSION).linux-armv6-sha256sum.txt |  | ||||||
| 	shasum -a 256 release/$(BINARY)-$(VERSION).windows-amd64.$(GO_VERSION)/$(BINARY) > release/$(BINARY)-$(VERSION).windows-amd64-sha256sum.txt |  | ||||||
| 	tar -C release -czvf release/$(BINARY)-$(VERSION).darwin-amd64.$(GO_VERSION).tar.gz $(BINARY)-$(VERSION).darwin-amd64.$(GO_VERSION) |  | ||||||
| 	tar -C release -czvf release/$(BINARY)-$(VERSION).linux-amd64.$(GO_VERSION).tar.gz $(BINARY)-$(VERSION).linux-amd64.$(GO_VERSION) |  | ||||||
| 	tar -C release -czvf release/$(BINARY)-$(VERSION).linux-arm64.$(GO_VERSION).tar.gz $(BINARY)-$(VERSION).linux-arm64.$(GO_VERSION) |  | ||||||
| 	tar -C release -czvf release/$(BINARY)-$(VERSION).linux-armv6.$(GO_VERSION).tar.gz $(BINARY)-$(VERSION).linux-armv6.$(GO_VERSION) |  | ||||||
| 	tar -C release -czvf release/$(BINARY)-$(VERSION).windows-amd64.$(GO_VERSION).tar.gz $(BINARY)-$(VERSION).windows-amd64.$(GO_VERSION) |  | ||||||
|  |  | ||||||
							
								
								
									
										83
									
								
								dist.sh
								
								
								
								
							
							
						
						
									
										83
									
								
								dist.sh
								
								
								
								
							|  | @ -1,45 +1,46 @@ | ||||||
| #!/bin/bash | #!/usr/bin/env bash | ||||||
| # build binary distributions for linux/amd64 and darwin/amd64 |  | ||||||
| set -e |  | ||||||
| 
 | 
 | ||||||
| DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | set -o errexit | ||||||
| echo "working dir $DIR" |  | ||||||
| mkdir -p $DIR/dist |  | ||||||
| dep ensure || exit 1 |  | ||||||
| 
 | 
 | ||||||
| os=$(go env GOOS) | if [[ -z ${BINARY} ]] || [[ -z ${VERSION} ]]; then | ||||||
| arch=$(go env GOARCH) | 	echo "Missing required env var: BINARY=X VERSION=X $(basename $0)" | ||||||
| version=$(cat $DIR/version.go | grep "const VERSION" | awk '{print $NF}' | sed 's/"//g') | 	exit 1 | ||||||
| goversion=$(go version | awk '{print $3}') |  | ||||||
| sha256sum=() |  | ||||||
| 
 |  | ||||||
| echo "... running tests" |  | ||||||
| ./test.sh |  | ||||||
| 
 |  | ||||||
| for os in windows linux darwin; do |  | ||||||
|     echo "... building v$version for $os/$arch" |  | ||||||
|     EXT= |  | ||||||
|     if [ $os = windows ]; then |  | ||||||
|         EXT=".exe" |  | ||||||
|     fi |  | ||||||
|     BUILD=$(mktemp -d ${TMPDIR:-/tmp}/oauth2_proxy.XXXXXX) |  | ||||||
|     TARGET="oauth2_proxy-$version.$os-$arch.$goversion" |  | ||||||
|     FILENAME="oauth2_proxy-$version.$os-$arch$EXT" |  | ||||||
|     GOOS=$os GOARCH=$arch CGO_ENABLED=0 \ |  | ||||||
|         go build -ldflags="-s -w" -o $BUILD/$TARGET/$FILENAME || exit 1 |  | ||||||
|     pushd $BUILD/$TARGET |  | ||||||
|     sha256sum+=("$(shasum -a 256 $FILENAME || exit 1)") |  | ||||||
|     cd .. && tar czvf $TARGET.tar.gz $TARGET |  | ||||||
|     mv $TARGET.tar.gz $DIR/dist |  | ||||||
|     popd |  | ||||||
| done |  | ||||||
| 
 |  | ||||||
| checksum_file="sha256sum.txt" |  | ||||||
| cd $DIR/dist |  | ||||||
| if [ -f $checksum_file ]; then |  | ||||||
|     rm $checksum_file |  | ||||||
| fi | fi | ||||||
| touch $checksum_file | 
 | ||||||
| for checksum in "${sha256sum[@]}"; do | # Check for Go version 1.13.* | ||||||
|     echo "$checksum" >> $checksum_file | GO_VERSION=$(go version | awk '{print $3}') | ||||||
|  | if [[ ! "${GO_VERSION}" =~ ^go1.13.* ]]; then | ||||||
|  | 	echo "Go version must be >= go1.13" | ||||||
|  | 	exit 1 | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | ARCHS=(darwin-amd64 linux-amd64 linux-arm64 linux-armv6 windows-amd64) | ||||||
|  | 
 | ||||||
|  | mkdir -p release | ||||||
|  | 
 | ||||||
|  | # Create architecture specific release dirs | ||||||
|  | for ARCH in "${ARCHS[@]}"; do | ||||||
|  | 	mkdir -p release/${BINARY}-${VERSION}.${ARCH}.${GO_VERSION} | ||||||
|  | 
 | ||||||
|  | 	GO_OS=$(echo $ARCH | awk -F- '{print $1}') | ||||||
|  | 	GO_ARCH=$(echo $ARCH | awk -F- '{print $2}') | ||||||
|  | 
 | ||||||
|  | 	# Create architecture specific binaries | ||||||
|  | 	if [[ ${GO_ARCH} == "armv6" ]]; then | ||||||
|  | 		GO111MODULE=on GOOS=${GO_OS} GOARCH=arm GOARM=6 go build -ldflags="-X main.VERSION=${VERSION}" \ | ||||||
|  | 			-o release/${BINARY}-${VERSION}.${ARCH}.${GO_VERSION}/${BINARY} github.com/pusher/oauth2_proxy | ||||||
|  | 	else | ||||||
|  | 		GO111MODULE=on GOOS=${GO_OS} GOARCH=${GO_ARCH} go build -ldflags="-X main.VERSION=${VERSION}" \ | ||||||
|  | 			-o release/${BINARY}-${VERSION}.${ARCH}.${GO_VERSION}/${BINARY} github.com/pusher/oauth2_proxy | ||||||
|  | 	fi | ||||||
|  | 
 | ||||||
|  | 	cd release | ||||||
|  | 
 | ||||||
|  | 	# Create sha256sum for architecture specific binary | ||||||
|  | 	shasum -a 256 ${BINARY}-${VERSION}.${ARCH}.${GO_VERSION}/${BINARY} > ${BINARY}-${VERSION}.${ARCH}-sha256sum.txt | ||||||
|  | 
 | ||||||
|  | 	# Create tar file for architecture specific binary | ||||||
|  | 	tar -czvf ${BINARY}-${VERSION}.${ARCH}.${GO_VERSION}.tar.gz ${BINARY}-${VERSION}.${ARCH}.${GO_VERSION} | ||||||
|  | 
 | ||||||
|  | 	cd .. | ||||||
| done | done | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ nav_order: 1 | ||||||
| 
 | 
 | ||||||
| 1.  Choose how to deploy: | 1.  Choose how to deploy: | ||||||
| 
 | 
 | ||||||
|     a. Download [Prebuilt Binary](https://github.com/pusher/oauth2_proxy/releases) (current release is `v3.2.0`) |     a. Download [Prebuilt Binary](https://github.com/pusher/oauth2_proxy/releases) (current release is `v4.0.0`) | ||||||
| 
 | 
 | ||||||
|     b. Build with `$ go get github.com/pusher/oauth2_proxy` which will put the binary in `$GOROOT/bin` |     b. Build with `$ go get github.com/pusher/oauth2_proxy` which will put the binary in `$GOROOT/bin` | ||||||
| 
 | 
 | ||||||
|  | @ -18,8 +18,8 @@ nav_order: 1 | ||||||
| Prebuilt binaries can be validated by extracting the file and verifying it against the `sha256sum.txt` checksum file provided for each release starting with version `v3.0.0`. | Prebuilt binaries can be validated by extracting the file and verifying it against the `sha256sum.txt` checksum file provided for each release starting with version `v3.0.0`. | ||||||
| 
 | 
 | ||||||
| ``` | ``` | ||||||
| sha256sum -c sha256sum.txt 2>&1 | grep OK | $ sha256sum -c sha256sum.txt 2>&1 | grep OK | ||||||
| oauth2_proxy-3.2.0.linux-amd64: OK | oauth2_proxy-4.0.0.linux-amd64: OK | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| 2.  [Select a Provider and Register an OAuth Application with a Provider](auth-configuration) | 2.  [Select a Provider and Register an OAuth Application with a Provider](auth-configuration) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue