diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index b59573992f..82d42f62be 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -49,3 +49,14 @@ jobs: if [[ "$RUNNER_OS" == "Linux" ]]; then docker run ${testimg} --wait=false -f HEAD fi + + # Check that using ldflags to set variables works. + cat > .ko.yaml << EOF + builds: + - id: test + main: ./test/ + ldflags: + - "-X main.version=${{ github.sha }}" + EOF + docker run $(go run ./ publish ./test/ --platform=${GOOS}/${GOARCH}) --wait=false 2>&1 | grep "${{ github.sha }}" + diff --git a/.ko.yaml b/.ko.yaml deleted file mode 100644 index 6ccd2d5eb9..0000000000 --- a/.ko.yaml +++ /dev/null @@ -1 +0,0 @@ -defaultBaseImage: gcr.io/distroless/static:nonroot diff --git a/test/main.go b/test/main.go index ae9ce230fb..aba10d995c 100644 --- a/test/main.go +++ b/test/main.go @@ -29,9 +29,14 @@ var ( wait = flag.Bool("wait", true, "Whether to wait for SIGTERM") ) +// This is defined so we can test build-time variable setting using ldflags. +var version = "default" + func main() { flag.Parse() + log.Println("version =", version) + dp := os.Getenv("KO_DATA_PATH") file := filepath.Join(dp, *f) bytes, err := ioutil.ReadFile(file)