From 09bfa18f470c18a67e060828e4554a2dbad882c7 Mon Sep 17 00:00:00 2001 From: Daniel Holbach Date: Wed, 2 Nov 2022 09:12:06 +0100 Subject: [PATCH] simplify the setup of go in workflows Signed-off-by: Daniel Holbach --- .github/workflows/on-main-push.yaml | 8 +------- .github/workflows/on-pr.yaml | 28 ++++---------------------- .github/workflows/on-tag.yaml | 7 +------ .github/workflows/periodics-daily.yaml | 7 +------ 4 files changed, 7 insertions(+), 43 deletions(-) diff --git a/.github/workflows/on-main-push.yaml b/.github/workflows/on-main-push.yaml index 4581369..09c2197 100644 --- a/.github/workflows/on-main-push.yaml +++ b/.github/workflows/on-main-push.yaml @@ -21,16 +21,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Find go version - run: | - GO_VERSION=$(awk '/^go/ {print $2};' go.mod) - echo "::set-output name=version::${GO_VERSION}" - id: awk_gomod - - name: Ensure go version uses: actions/setup-go@v3 with: - go-version: "${{ steps.awk_gomod.outputs.version }}" + go-version-file: 'go.mod' check-latest: true - name: Login to ghcr.io diff --git a/.github/workflows/on-pr.yaml b/.github/workflows/on-pr.yaml index 0f20c60..71ea50c 100644 --- a/.github/workflows/on-pr.yaml +++ b/.github/workflows/on-pr.yaml @@ -10,15 +10,10 @@ jobs: steps: - name: checkout uses: actions/checkout@v3 - - name: Find go version - run: | - GO_VERSION=$(awk '/^go/ {print $2};' go.mod) - echo "::set-output name=version::${GO_VERSION}" - id: awk_gomod - name: Ensure go version uses: actions/setup-go@v3 with: - go-version: "${{ steps.awk_gomod.outputs.version }}" + go-version-file: 'go.mod' check-latest: true - name: run tests run: go test -json ./... > test.json @@ -41,15 +36,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Find go version - run: | - GO_VERSION=$(awk '/^go/ {print $2};' go.mod) - echo "::set-output name=version::${GO_VERSION}" - id: awk_gomod - name: Ensure go version uses: actions/setup-go@v3 with: - go-version: "${{ steps.awk_gomod.outputs.version }}" + go-version-file: 'go.mod' check-latest: true - name: Lint cmd folder uses: Jerome1337/golint-action@v1.0.2 @@ -81,15 +71,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Find go version - run: | - GO_VERSION=$(awk '/^go/ {print $2};' go.mod) - echo "::set-output name=version::${GO_VERSION}" - id: awk_gomod - name: Ensure go version uses: actions/setup-go@v3 with: - go-version: "${{ steps.awk_gomod.outputs.version }}" + go-version-file: 'go.mod' check-latest: true - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -127,15 +112,10 @@ jobs: - "1.25" steps: - uses: actions/checkout@v3 - - name: Find go version - run: | - GO_VERSION=$(awk '/^go/ {print $2};' go.mod) - echo "::set-output name=version::${GO_VERSION}" - id: awk_gomod - name: Ensure go version uses: actions/setup-go@v3 with: - go-version: "${{ steps.awk_gomod.outputs.version }}" + go-version-file: 'go.mod' check-latest: true - name: Set up QEMU uses: docker/setup-qemu-action@v2 diff --git a/.github/workflows/on-tag.yaml b/.github/workflows/on-tag.yaml index 1cc83f3..d3e7b01 100644 --- a/.github/workflows/on-tag.yaml +++ b/.github/workflows/on-tag.yaml @@ -22,15 +22,10 @@ jobs: packages: write steps: - uses: actions/checkout@v3 - - name: Find go version - run: | - GO_VERSION=$(awk '/^go/ {print $2};' go.mod) - echo "::set-output name=version::${GO_VERSION}" - id: awk_gomod - name: Ensure go version uses: actions/setup-go@v3 with: - go-version: "${{ steps.awk_gomod.outputs.version }}" + go-version-file: 'go.mod' check-latest: true - name: Find current tag version run: echo "::set-output name=version::${GITHUB_REF#refs/tags/}" diff --git a/.github/workflows/periodics-daily.yaml b/.github/workflows/periodics-daily.yaml index b188c1c..fd08a70 100644 --- a/.github/workflows/periodics-daily.yaml +++ b/.github/workflows/periodics-daily.yaml @@ -53,15 +53,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Find go version - run: | - GO_VERSION=$(awk '/^go/ {print $2};' go.mod) - echo "::set-output name=version::${GO_VERSION}" - id: awk_gomod - name: Ensure go version uses: actions/setup-go@v3 with: - go-version: "${{ steps.awk_gomod.outputs.version }}" + go-version-file: 'go.mod' check-latest: true - name: Set up QEMU uses: docker/setup-qemu-action@v2