From 0bc79b8834034afbf153a0230c67ef212708e481 Mon Sep 17 00:00:00 2001 From: Horst Gutmann Date: Mon, 15 Jan 2024 17:00:48 +0100 Subject: [PATCH] chore: Use Dockerfile as source for the Go version --- .github/actions/setup-goversion/action.yml | 11 +++++++++++ .github/workflows/release.yml | 4 +--- .github/workflows/tests.yml | 12 +++--------- 3 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 .github/actions/setup-goversion/action.yml diff --git a/.github/actions/setup-goversion/action.yml b/.github/actions/setup-goversion/action.yml new file mode 100644 index 000000000..2570615af --- /dev/null +++ b/.github/actions/setup-goversion/action.yml @@ -0,0 +1,11 @@ +name: setup-goversion +runs: + using: composite + steps: + - id: goversion + run: | + cat Dockerfile | awk '/^FROM golang:.* as build$/ {v=$2;split(v,a,":")}; END {printf("version=%s", a[2])}' >> $GITHUB_OUTPUT + shell: bash + - uses: actions/setup-go@v5 + with: + go-version: "${{steps.goversion.outputs.version}}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d374c8eb1..863a658ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,9 +15,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-tags: true - - uses: actions/setup-go@v5 - with: - go-version: '1.20' + - uses: ./.github/actions/setup-goversion - run: make cross - id: docker_tag run: echo "DOCKER_TAG=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index cccee8942..24969d893 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,18 +13,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: '1.20' + - uses: ./.github/actions/setup-goversion - run: make lint test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: '1.20' + - uses: ./.github/actions/setup-goversion - uses: azure/setup-helm@v3 with: version: '3.13.1' @@ -36,7 +32,5 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: '1.20' + - uses: ./.github/actions/setup-goversion - run: make cross