Skip to content

Commit

Permalink
Backport of ci: Single source of truth for Go version in CI and Docke…
Browse files Browse the repository at this point in the history
…rfile into release/1.15.x (#20162)

* backport of commit ea888cd

* ci: fix pull request labeler check
  • Loading branch information
zalimeni committed Jan 11, 2024
1 parent 9c7f964 commit 977b2dc
Show file tree
Hide file tree
Showing 17 changed files with 192 additions and 80 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ jobs:
name: Setup outputs
run: ./.github/scripts/get_runner_classes.sh

get-go-version:
uses: ./.github/workflows/reusable-get-go-version.yml

dev-build-push:
needs: setup
needs:
- setup
- get-go-version
runs-on: ${{ fromJSON(needs.setup.outputs.compute-large) }}
permissions:
id-token: write # NOTE: this permission is explicitly required for Vault auth.
Expand Down Expand Up @@ -65,7 +70,7 @@ jobs:

- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0
with:
go-version-file: 'go.mod'
go-version: ${{ needs.get-go-version.outputs.go-version }}

- run: go env

Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/build-distros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,25 @@ jobs:
name: Setup outputs
run: ./.github/scripts/get_runner_classes.sh

get-go-version:
uses: ./.github/workflows/reusable-get-go-version.yml

check-go-mod:
needs:
- setup
- get-go-version
uses: ./.github/workflows/reusable-check-go-mod.yml
with:
runs-on: ${{ needs.setup.outputs.compute-medium }}
repository-name: ${{ github.repository }}
go-version: ${{ needs.get-go-version.outputs.go-version }}
secrets:
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}

build-386:
needs:
- setup
- get-go-version
- check-go-mod
env:
XC_OS: "freebsd linux windows"
Expand All @@ -59,7 +65,7 @@ jobs:

- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
go-version: ${{ needs.get-go-version.outputs.go-version }}
- name: Build
run: |
for os in $XC_OS; do
Expand All @@ -69,6 +75,7 @@ jobs:
build-amd64:
needs:
- setup
- get-go-version
- check-go-mod
env:
XC_OS: "darwin freebsd linux solaris windows"
Expand All @@ -83,7 +90,7 @@ jobs:

- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
go-version: ${{ needs.get-go-version.outputs.go-version }}
- name: Build
run: |
for os in $XC_OS; do
Expand All @@ -93,6 +100,7 @@ jobs:
build-arm:
needs:
- setup
- get-go-version
- check-go-mod
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
env:
Expand All @@ -109,7 +117,7 @@ jobs:

- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
go-version: ${{ needs.get-go-version.outputs.go-version }}
- run: |
sudo apt-get update --allow-releaseinfo-change-suite --allow-releaseinfo-change-version && sudo apt-get install -y gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
Expand All @@ -122,6 +130,7 @@ jobs:
if: ${{ endsWith(github.repository, '-enterprise') }}
needs:
- setup
- get-go-version
- check-go-mod
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
steps:
Expand All @@ -133,7 +142,7 @@ jobs:

- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
go-version: ${{ needs.get-go-version.outputs.go-version }}
- name: Build
run: GOOS=linux GOARCH=s390x CGO_ENABLED=0 go build -tags "${{ env.GOTAGS }}"

Expand Down
58 changes: 28 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ env:
GOPRIVATE: github.com/hashicorp # Required for enterprise deps

jobs:
get-go-version:
uses: ./.github/workflows/reusable-get-go-version.yml

set-product-version:
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -81,32 +84,25 @@ jobs:
path: ${{ steps.generate-metadata-file.outputs.filepath }}

build:
needs: set-product-version
needs:
- set-product-version
- get-go-version
runs-on: ubuntu-latest
strategy:
matrix:
include:
- {go: "1.20.12",
goos: "linux", goarch: "386"}
- {go: "1.20.12",
goos: "linux", goarch: "amd64"}
- {go: "1.20.12",
goos: "linux", goarch: "arm"}
- {go: "1.20.12",
goos: "linux", goarch: "arm64"}
- {go: "1.20.12",
goos: "freebsd", goarch: "386"}
- {go: "1.20.12",
goos: "freebsd", goarch: "amd64"}
- {go: "1.20.12",
goos: "windows", goarch: "386"}
- {go: "1.20.12",
goos: "windows", goarch: "amd64"}
- {go: "1.20.12",
goos: "solaris", goarch: "amd64"}
- {goos: "linux", goarch: "386"}
- {goos: "linux", goarch: "amd64"}
- {goos: "linux", goarch: "arm"}
- {goos: "linux", goarch: "arm64"}
- {goos: "freebsd", goarch: "386"}
- {goos: "freebsd", goarch: "amd64"}
- {goos: "windows", goarch: "386"}
- {goos: "windows", goarch: "amd64"}
- {goos: "solaris", goarch: "amd64"}
fail-fast: true

name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

Expand Down Expand Up @@ -140,7 +136,7 @@ jobs:
with:
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ matrix.go }}
go_version: ${{ needs.get-go-version.outputs.go-version }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
Expand Down Expand Up @@ -186,17 +182,18 @@ jobs:
path: out/${{ env.DEB_PACKAGE }}

build-s390x:
needs: set-product-version
needs:
- set-product-version
- get-go-version
if: ${{ endsWith(github.repository, '-enterprise') }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- {go: "1.20.12",
goos: "linux", goarch: "s390x"}
- {goos: "linux", goarch: "s390x"}
fail-fast: true

name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

Expand Down Expand Up @@ -230,24 +227,25 @@ jobs:
with:
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ matrix.go }}
go_version: ${{ needs.get-go-version.outputs.go-version }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
go build -ldflags="$GOLDFLAGS" -o "$BIN_PATH" -trimpath -buildvcs=false
build-darwin:
needs: set-product-version
needs:
- set-product-version
- get-go-version
runs-on: macos-latest
strategy:
matrix:
goos: [ darwin ]
goarch: [ "amd64", "arm64" ]
go: [ "1.20.12" ]
fail-fast: true

name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

Expand Down Expand Up @@ -279,7 +277,7 @@ jobs:
with:
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ matrix.go }}
go_version: ${{ needs.get-go-version.outputs.go-version }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
Expand Down
Loading

0 comments on commit 977b2dc

Please sign in to comment.