Skip to content

Commit

Permalink
Refactor: use ghcp for assets release and tidy up (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
int128 authored Jan 23, 2020
1 parent ea28847 commit ffa53f6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 38 deletions.
20 changes: 9 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,24 @@ jobs:
docker:
- image: circleci/golang:1.13.3
steps:
- run: |
mkdir -p ~/bin
echo 'export PATH="$HOME/bin:$PATH"' >> $BASH_ENV
- run: |
curl -L -o ~/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.14.0/bin/linux/amd64/kubectl
chmod +x ~/bin/kubectl
- run: mkdir -p ~/bin
- run: echo 'export PATH="$HOME/bin:$PATH"' >> $BASH_ENV
- run: |
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b ~/bin v1.21.0
# https://github.com/int128/goxzst
- run: |
curl -sfL -o /tmp/goxzst.zip https://github.com/int128/goxzst/releases/download/v0.3.0/goxzst_linux_amd64.zip
unzip /tmp/goxzst.zip -d ~/bin
# https://github.com/int128/ghcp
- run: |
go get github.com/int128/goxzst
curl -sfL -o /tmp/ghcp.zip https://github.com/int128/ghcp/releases/download/v1.8.0/ghcp_linux_amd64.zip
unzip /tmp/ghcp.zip -d ~/bin
- checkout
- run: make check
- run: bash <(curl -s https://codecov.io/bash)
- run: make run
- run: make dist
- run: |
if [ "$CIRCLE_TAG" ]; then
go get github.com/tcnksm/ghr
curl -L -o ~/bin/ghcp https://github.com/int128/ghcp/releases/download/v1.5.0/ghcp_linux_amd64
chmod +x ~/bin/ghcp
make release
fi
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/.idea

/dist
/dist/output
/coverage.out
/kubectl-oidc_port_forward
/kauthproxy
42 changes: 17 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
TARGET := kauthproxy
TARGET_PLUGIN := kubectl-auth_proxy
CIRCLE_TAG ?= HEAD
CIRCLE_TAG ?= latest
LDFLAGS := -X main.version=$(CIRCLE_TAG)

.PHONY: all
Expand All @@ -11,38 +10,31 @@ check:
golangci-lint run
go test -v -race -cover -coverprofile=coverage.out ./...

$(TARGET): $(wildcard *.go)
$(TARGET): $(wildcard **/*.go)
go build -o $@ -ldflags "$(LDFLAGS)"

$(TARGET_PLUGIN): $(TARGET)
ln -sf $(TARGET) $@

.PHONY: run
run: $(TARGET_PLUGIN)
PATH=.:$(PATH) kubectl auth-proxy --help

dist:
# make the zip files for GitHub Releases
VERSION=$(CIRCLE_TAG) goxzst -d dist/gh/ -i "LICENSE" -o "$(TARGET)" -t "kauthproxy.rb auth-proxy.yaml" -- -ldflags "$(LDFLAGS)"
zipinfo dist/gh/kauthproxy_linux_amd64.zip
# make the Homebrew formula
mv dist/gh/kauthproxy.rb dist/
# make the yaml for krew-index
mkdir -p dist/plugins
cp dist/gh/auth-proxy.yaml dist/plugins/auth-proxy.yaml
.PHONY: dist
dist: dist/output
dist/output:
# make the zip files for GitHub Releases
VERSION=$(CIRCLE_TAG) CGO_ENABLED=0 goxzst -d dist/output/ -i "LICENSE" -o "$(TARGET)" -t "dist/kauthproxy.rb dist/auth-proxy.yaml" -- -ldflags "$(LDFLAGS)"
# test the zip file
zipinfo dist/output/kauthproxy_linux_amd64.zip
# make the krew yaml structure
mkdir -p dist/output/plugins
mv dist/output/auth-proxy.yaml dist/output/plugins/auth-proxy.yaml

.PHONY: release
release: dist
# publish to GitHub Releases
ghr -u "$(CIRCLE_PROJECT_USERNAME)" -r "$(CIRCLE_PROJECT_REPONAME)" "$(CIRCLE_TAG)" dist/gh/
# publish to GitHub Releases
ghcp release -u "$(CIRCLE_PROJECT_USERNAME)" -r "$(CIRCLE_PROJECT_REPONAME)" -t "$(CIRCLE_TAG)" dist/output/
# publish to Homebrew tap repository
ghcp commit -u "$(CIRCLE_PROJECT_USERNAME)" -r "homebrew-$(CIRCLE_PROJECT_REPONAME)" -m "$(CIRCLE_TAG)" -C dist/ kauthproxy.rb
ghcp commit -u "$(CIRCLE_PROJECT_USERNAME)" -r "homebrew-$(CIRCLE_PROJECT_REPONAME)" -b "bump-$(CIRCLE_TAG)" -m "Bump version to $(CIRCLE_TAG)" -C dist/ kauthproxy.rb
# fork krew-index and create a branch
ghcp fork-commit -u kubernetes-sigs -r krew-index -b "auth-proxy-$(CIRCLE_TAG)" -m "Bump auth-proxy to $(CIRCLE_TAG)" -C dist/ plugins/auth-proxy.yaml
ghcp fork-commit -u kubernetes-sigs -r krew-index -b "auth-proxy-$(CIRCLE_TAG)" -m "Bump auth-proxy to $(CIRCLE_TAG)" -C dist/output/ plugins/auth-proxy.yaml

.PHONY: clean
clean:
-rm $(TARGET)
-rm $(TARGET_PLUGIN)
-rm -r dist/
-rm -r dist/output/
-rm coverage.out
File renamed without changes.
File renamed without changes.

0 comments on commit ffa53f6

Please sign in to comment.