Skip to content

Commit

Permalink
Determine go version from .circleci/config.yml (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
int128 authored Aug 2, 2020
1 parent 58d170f commit 488e8c6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
17 changes: 17 additions & 0 deletions .circleci/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.PHONY: all
all:

.PHONY: install-test-deps
install-test-deps:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(HOME)/go/bin v1.24.0
go get -v github.com/int128/goxzst

.PHONY: install-release-deps
install-release-deps: go
go get -v github.com/int128/goxzst github.com/int128/ghcp

go:
curl -sSfL -o go.tgz "https://golang.org/dl/go`ruby go_version_from_config.rb < config.yml`.darwin-amd64.tar.gz"
tar -xf go.tgz
rm go.tgz
./go/bin/go version
21 changes: 9 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ jobs:
docker:
- image: cimg/go:1.14.4
steps:
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.24.0
- checkout
- restore_cache:
keys:
- go-sum-{{ checksum "go.sum" }}
- run: make -C .circleci install-test-deps
- run: make check
- run: bash <(curl -s https://codecov.io/bash)
- run:
command: go get -v github.com/int128/goxzst
working_directory: .circleci
- run: make dist
- save_cache:
key: go-sum-{{ checksum "go.sum" }}
Expand All @@ -25,20 +22,20 @@ jobs:

release:
macos:
# https://circleci.com/docs/2.0/testing-ios/
xcode: 11.5.0
steps:
- run: |
curl -sSfL https://dl.google.com/go/go1.14.4.darwin-amd64.tar.gz | tar -C /tmp -xz
echo 'export PATH="$PATH:/tmp/go/bin:$HOME/go/bin"' >> $BASH_ENV
- run: echo 'export PATH="$HOME/go/bin:$PWD/.circleci/go/bin:$PATH"' >> $BASH_ENV
- checkout
- restore_cache:
keys:
- go-macos-{{ checksum "go.sum" }}
- run:
command: go get -v github.com/int128/goxzst github.com/int128/ghcp
working_directory: .circleci
- run: make -C .circleci install-release-deps
- run: make dist
- run: make release
- run: |
if [ "$CIRCLE_TAG" ]; then
make release
fi
- save_cache:
key: go-macos-{{ checksum "go.sum" }}
paths:
Expand All @@ -58,6 +55,6 @@ workflows:
- test
filters:
branches:
ignore: /.*/
only: /^release-feature.*/
tags:
only: /^v.*/
11 changes: 11 additions & 0 deletions .circleci/go_version_from_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'yaml'

config = YAML.load(STDIN)

image = config["jobs"]["test"]["docker"][0]["image"]
if !image.start_with?("cimg/go:")
raise "unknown image #{image} in #{configPath}"
end

goVersion = image.delete_prefix("cimg/go:")
print(goVersion)
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@

/kubelogin
/kubectl-oidc_login

/.circleci/go/

0 comments on commit 488e8c6

Please sign in to comment.