Browse Source

refactor build workflows to contain universal logic for oss v. ent builder types

pull/16748/head
Morgan Drake 2 years ago
parent
commit
99f270b4fd
  1. 25
      .github/workflows/build-distros.yml
  2. 43
      .github/workflows/build.yml

25
.github/workflows/build-distros.yml

@ -8,8 +8,25 @@ permissions:
contents: read contents: read
jobs: jobs:
setup: # Detect oss v. ent and set runner type
name: Setup
runs-on: ubuntu-latest
outputs:
runner-standard: ${{ steps.setup-outputs.outputs.runner-standard }}
steps:
- id: setup-outputs
name: Setup outputs
run: |
github_repository="${{ github.repository }}"
if [ "${github_repository##*/}" == "consul-enterprise" ] ; then
echo 'runner-standard=["self-hosted","linux"]' >> $GITHUB_OUTPUT
echo 'enterprise=1' >> $GITHUB_OUTPUT
else
echo 'runner-standard=["ubuntu-22.04"]' >> $GITHUB_OUTPUT
echo 'enterprise=' >> $GITHUB_OUTPUT
fi
check-go-mod: check-go-mod:
runs-on: ubuntu-22.04 runs-on: ${{ fromJSON(needs.setup.outputs.runner-standard) }}
steps: steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0 - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0 - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0
@ -27,7 +44,7 @@ jobs:
needs: check-go-mod needs: check-go-mod
env: env:
XC_OS: "freebsd linux windows" XC_OS: "freebsd linux windows"
runs-on: ubuntu-22.04 runs-on: ${{ fromJSON(needs.setup.outputs.runner-standard) }}
steps: steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0 - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0 - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0
@ -43,7 +60,7 @@ jobs:
needs: check-go-mod needs: check-go-mod
env: env:
XC_OS: "darwin freebsd linux solaris windows" XC_OS: "darwin freebsd linux solaris windows"
runs-on: ubuntu-22.04 runs-on: ${{ fromJSON(needs.setup.outputs.runner-standard) }}
steps: steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0 - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # pin@v3.3.0
- uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0 - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # pin@v3.5.0
@ -57,7 +74,7 @@ jobs:
build-arm: build-arm:
needs: check-go-mod needs: check-go-mod
runs-on: ubuntu-22.04 runs-on: ${{ fromJSON(needs.setup.outputs.runner-standard) }}
env: env:
CGO_ENABLED: 1 CGO_ENABLED: 1
GOOS: linux GOOS: linux

43
.github/workflows/build.yml

@ -16,8 +16,27 @@ env:
METADATA: oss METADATA: oss
jobs: jobs:
set-product-version: setup: # Detect oss v. ent and set runner type
name: Setup
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
runner-standard: ${{ steps.setup-outputs.outputs.runner-standard }}
steps:
- id: setup-outputs
name: Setup outputs
run: |
github_repository="${{ github.repository }}"
if [ "${github_repository##*/}" == "consul-enterprise" ] ; then
echo 'linux-runner-standard=["self-hosted","linux"]' >> $GITHUB_OUTPUT
echo 'macos-runner-standard-macos=["self-hosted","ondemand","os=macos"]' >> $GITHUB_OUTPUT
echo 'enterprise=1' >> $GITHUB_OUTPUT
else
echo 'linux-runner-standard=["ubuntu-latest"]' >> $GITHUB_OUTPUT
echo 'macos-runner-standard=["macos-latest"]' >> $GITHUB_OUTPUT
echo 'enterprise=' >> $GITHUB_OUTPUT
fi
set-product-version:
runs-on: ${{ fromJSON(needs.setup.outputs.linux-runner-standard) }}
outputs: outputs:
product-version: ${{ steps.set-product-version.outputs.product-version }} product-version: ${{ steps.set-product-version.outputs.product-version }}
base-product-version: ${{ steps.set-product-version.outputs.base-product-version }} base-product-version: ${{ steps.set-product-version.outputs.base-product-version }}
@ -46,7 +65,7 @@ jobs:
" "
validate-outputs: validate-outputs:
needs: set-product-version needs: set-product-version
runs-on: ubuntu-latest runs-on: ${{ fromJSON(needs.setup.outputs.linux-runner-standard) }}
steps: steps:
- name: Validate Outputs - name: Validate Outputs
run: | run: |
@ -58,7 +77,7 @@ jobs:
echo "Ldflags: ${{ needs.set-product-version.outputs.shared-ldflags }}" echo "Ldflags: ${{ needs.set-product-version.outputs.shared-ldflags }}"
generate-metadata-file: generate-metadata-file:
needs: set-product-version needs: set-product-version
runs-on: ubuntu-latest runs-on: ${{ fromJSON(needs.setup.outputs.linux-runner-standard) }}
outputs: outputs:
filepath: ${{ steps.generate-metadata-file.outputs.filepath }} filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
steps: steps:
@ -78,7 +97,7 @@ jobs:
build: build:
needs: set-product-version needs: set-product-version
runs-on: ubuntu-latest runs-on: ${{ fromJSON(needs.setup.outputs.linux-runner-standard) }}
strategy: strategy:
matrix: matrix:
include: include:
@ -174,7 +193,7 @@ jobs:
build-darwin: build-darwin:
needs: set-product-version needs: set-product-version
runs-on: macos-latest runs-on: ${{ fromJSON(needs.setup.outputs.macos-runner-standard) }}
strategy: strategy:
matrix: matrix:
goos: [ darwin ] goos: [ darwin ]
@ -226,7 +245,7 @@ jobs:
needs: needs:
- set-product-version - set-product-version
- build - build
runs-on: ubuntu-latest runs-on: ${{ fromJSON(needs.setup.outputs.linux-runner-standard) }}
strategy: strategy:
matrix: matrix:
arch: ["386", "amd64", "arm", "arm64"] arch: ["386", "amd64", "arm", "arm64"]
@ -263,7 +282,7 @@ jobs:
needs: needs:
- set-product-version - set-product-version
- build - build
runs-on: ubuntu-latest runs-on: ${{ fromJSON(needs.setup.outputs.linux-runner-standard) }}
env: env:
repo: ${{github.event.repository.name}} repo: ${{github.event.repository.name}}
version: ${{needs.set-product-version.outputs.product-version}} version: ${{needs.set-product-version.outputs.product-version}}
@ -283,7 +302,7 @@ jobs:
needs: needs:
- set-product-version - set-product-version
- build - build
runs-on: ubuntu-latest runs-on: ${{ fromJSON(needs.setup.outputs.linux-runner-standard) }}
env: env:
repo: ${{github.event.repository.name}} repo: ${{github.event.repository.name}}
version: ${{needs.set-product-version.outputs.product-version}} version: ${{needs.set-product-version.outputs.product-version}}
@ -315,7 +334,7 @@ jobs:
needs: needs:
- set-product-version - set-product-version
- build - build
runs-on: ubuntu-latest runs-on: ${{ fromJSON(needs.setup.outputs.linux-runner-standard) }}
strategy: strategy:
matrix: matrix:
arch: ["386", "amd64", "arm", "arm64"] arch: ["386", "amd64", "arm", "arm64"]
@ -347,7 +366,7 @@ jobs:
needs: needs:
- set-product-version - set-product-version
- build-darwin - build-darwin
runs-on: macos-latest runs-on: ${{ fromJSON(needs.setup.outputs.macos-runner-standard) }}
strategy: strategy:
fail-fast: true fail-fast: true
env: env:
@ -373,7 +392,7 @@ jobs:
needs: needs:
- build - build
- set-product-version - set-product-version
runs-on: ubuntu-latest runs-on: ${{ fromJSON(needs.setup.outputs.linux-runner-standard) }}
strategy: strategy:
matrix: matrix:
arch: ["i386", "amd64", "armhf", "arm64"] arch: ["i386", "amd64", "armhf", "arm64"]
@ -410,7 +429,7 @@ jobs:
needs: needs:
- build - build
- set-product-version - set-product-version
runs-on: ubuntu-latest runs-on: ${{ fromJSON(needs.setup.outputs.linux-runner-standard) }}
strategy: strategy:
matrix: matrix:
# TODO(eculver): re-enable when there is a smaller verification container available # TODO(eculver): re-enable when there is a smaller verification container available

Loading…
Cancel
Save