Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a98fa8d
Onboard consul to use new .release/VERSION file and reproducible acti…
claire-labry Nov 30, 2022
8152ecf
Onboard consul to use new .release/VERSION file and reproducible actions
emilymianeil Nov 30, 2022
e9f33a1
Merge branch 'set-product-version' of https://github.com/hashicorp/co…
claire-labry Nov 30, 2022
be97ac9
Onboard consul to use new .release/VERSION file and reproducible actions
emilymianeil Nov 30, 2022
83dbb23
Merge branch 'set-product-version' of https://github.com/hashicorp/co…
claire-labry Nov 30, 2022
8c98f5f
fix to consul
claire-labry Nov 30, 2022
78ee14f
Onboard consul to use new .release/VERSION file and reproducible actions
emilymianeil Nov 30, 2022
5e23cd7
Merge branch 'set-product-version' of https://github.com/hashicorp/co…
claire-labry Nov 30, 2022
607b309
Onboard consul to use new .release/VERSION file and reproducible actions
emilymianeil Nov 30, 2022
1bb4b45
Merge branch 'set-product-version' of https://github.com/hashicorp/co…
claire-labry Nov 30, 2022
b310777
Onboard consul to use new .release/VERSION file and reproducible actions
emilymianeil Nov 30, 2022
5aaf6e4
test out ent changes
sarahethompson Dec 5, 2022
0546c6e
just or testing
sarahethompson Dec 5, 2022
2ff351a
Added setup go for build ui
emilymianeil Dec 5, 2022
4c097b8
Merge branch 'set-product-version' of https://github.com/hashicorp/co…
claire-labry Dec 6, 2022
9bfc23d
try removing VERSION file out of .release dir
claire-labry Dec 6, 2022
473f281
add checkout action for build ui and update checkout version
claire-labry Dec 6, 2022
6ef395d
try no -dev marker
claire-labry Dec 6, 2022
c977e4c
try removing extra ldflags
claire-labry Dec 6, 2022
5caad41
test version
claire-labry Dec 6, 2022
c3b96fb
add back in setup-go step?
sarahethompson Dec 6, 2022
e9d0646
Update utils.js
sarahethompson Dec 6, 2022
71b7e46
remove actions-setup go
claire-labry Dec 6, 2022
6e5129c
add 1.15.0-dev
claire-labry Dec 6, 2022
fc4a05f
Merge branch 'main' into set-product-version
claire-labry Dec 6, 2022
e14b645
Using prepare workflow for pre-stable channel workflow
emilymianeil Dec 7, 2022
046afb2
Test prepare workflow
emilymianeil Dec 7, 2022
50984a9
Remove set-product-version branch from release pipeline
emilymianeil Dec 9, 2022
92e34a4
Use METADATA in environment
hc-github-team-nomad-core Jan 5, 2023
c551766
Correct env vars
hc-github-team-nomad-core Jan 5, 2023
bbd1cb0
Remove current branch from build trigger list
hc-github-team-nomad-core Jan 5, 2023
76a14dc
Merge branch 'main' into set-product-version
emilymianeil Jan 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 92 additions & 92 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,62 @@ on:

env:
PKG_NAME: consul
METADATA: oss

jobs:
get-product-version:
set-product-version:
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.get-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 }}
product-date: ${{ steps.get-product-version.outputs.product-date }}
pre-version: ${{ steps.get-product-version.outputs.pre-version }}
pkg-version: ${{ steps.get-product-version.outputs.pkg-version }}
pre-version: ${{ steps.set-product-version.outputs.prerelease-product-version }}
shared-ldflags: ${{ steps.shared-ldflags.outputs.shared-ldflags }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: set product version
id: set-product-version
uses: hashicorp/actions-set-product-version@v1
- name: get product version
id: get-product-version
run: |
CONSUL_VERSION=$(build-support/scripts/version.sh -r)
CONSUL_DATE=$(build-support/scripts/build-date.sh)
## TODO: This assumes `make version` outputs 1.1.1+ent-prerel
IFS="+" read VERSION _other <<< "$CONSUL_VERSION"
IFS="-" read _other PREREL_VERSION <<< "$CONSUL_VERSION"
## TODO: this assumes `version.sh` outputs in the expected ordering of
## [version]+ent{-prerelease} If we need to transition to
## [version]{-prerelease}+ent before then, we'll need to add
## logic to handle presense/absence of the prerelease
echo "::set-output name=product-version::${CONSUL_VERSION}"
echo "::set-output name=product-date::${CONSUL_DATE}"
echo "::set-output name=pre-version::${PREREL_VERSION}"
echo "::set-output name=pkg-version::${VERSION}"

- name: Set shared -ldflags
id: shared-ldflags
run: |
T="github.com/hashicorp/consul/version"
echo "::set-output name=shared-ldflags::-X ${T}.GitCommit=${GITHUB_SHA::8} -X ${T}.GitDescribe=${{ steps.get-product-version.outputs.product-version }} -X ${T}.BuildDate=${{ steps.get-product-version.outputs.product-date }}"

echo "::set-output name=shared-ldflags::-X ${T}.GitCommit=${GITHUB_SHA::8} \
-X ${T}.GitDescribe=${{ steps.set-product-version.outputs.product-version }} \
-X ${T}.BuildDate=${{ steps.get-product-version.outputs.product-date }} \
"
validate-outputs:
needs: set-product-version
runs-on: ubuntu-latest
steps:
- name: Validate Outputs
run: |
echo "Product Version: ${{ needs.set-product-version.outputs.product-version }}"
echo "Base Product Version: ${{ needs.set-product-version.outputs.base-product-version }}"
echo "Product Metadata: ${{ env.METADATA }}"
echo "Product Date: ${{ needs.set-product-version.outputs.product-date }}"
echo "Prerelease Version: ${{ needs.set-product-version.outputs.pre-version }}"
echo "Ldflags: ${{ needs.set-product-version.outputs.shared-ldflags }}"
generate-metadata-file:
needs: get-product-version
needs: set-product-version
runs-on: ubuntu-latest
outputs:
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
steps:
- name: 'Checkout directory'
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Generate metadata file
id: generate-metadata-file
uses: hashicorp/actions-generate-metadata@v1
with:
version: ${{ needs.get-product-version.outputs.product-version }}
version: ${{ needs.set-product-version.outputs.product-version }}
product: ${{ env.PKG_NAME }}

- uses: actions/upload-artifact@v2
Expand All @@ -66,7 +74,7 @@ jobs:
path: ${{ steps.generate-metadata-file.outputs.filepath }}

build:
needs: get-product-version
needs: set-product-version
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -84,24 +92,19 @@ jobs:

name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@v2

- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- uses: actions/checkout@v3

- name: Setup with node and yarn
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'yarn'
cache-dependency-path: 'ui/yarn.lock'

- name: Build UI
run: |
CONSUL_VERSION=${{ needs.get-product-version.outputs.product-version }}
CONSUL_DATE=${{ needs.get-product-version.outputs.product-date }}
CONSUL_VERSION=${{ needs.set-product-version.outputs.product-version }}
CONSUL_DATE=${{ needs.set-product-version.outputs.product-date }}
CONSUL_BINARY_TYPE=${CONSUL_BINARY_TYPE}
CONSUL_COPYRIGHT_YEAR=$(git show -s --format=%cd --date=format:%Y HEAD)
echo "consul_version is ${CONSUL_VERSION}"
Expand All @@ -111,21 +114,22 @@ jobs:
cd ui && make && cd ..
rm -rf agent/uiserver/dist
mv ui/packages/consul-ui/dist agent/uiserver/
- name: Build
- name: Go Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
GOLDFLAGS: "${{needs.get-product-version.outputs.shared-ldflags}}"
run: |
mkdir dist out
go build -ldflags="$GOLDFLAGS" -o dist/ .
zip -r -j out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip dist/

- uses: actions/upload-artifact@v2
PRODUCT_VERSION: ${{ needs.set-product-version.outputs.product-version }}
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.pre-version }}
CGO_ENABLED: "0"
GOLDFLAGS: "${{needs.set-product-version.outputs.shared-ldflags}}"
uses: hashicorp/actions-go-build@v0.1.7
with:
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
path: out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ matrix.go }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
go build -ldflags="$GOLDFLAGS" -o "$BIN_PATH" -trimpath -buildvcs=false

- name: Package
if: ${{ matrix.goos == 'linux' }}
Expand All @@ -134,7 +138,7 @@ jobs:
name: ${{ github.event.repository.name }}
description: "Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure. "
arch: ${{ matrix.goarch }}
version: ${{ needs.get-product-version.outputs.product-version }}
version: ${{ needs.set-product-version.outputs.product-version }}
maintainer: "HashiCorp"
homepage: "https://github.com/hashicorp/consul"
license: "MPL-2.0"
Expand Down Expand Up @@ -166,7 +170,7 @@ jobs:
path: out/${{ env.DEB_PACKAGE }}

build-darwin:
needs: get-product-version
needs: set-product-version
runs-on: macos-latest
strategy:
matrix:
Expand All @@ -177,23 +181,18 @@ jobs:

name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
steps:
- uses: actions/checkout@v2

- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- uses: actions/checkout@v3

- name: Setup with node and yarn
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'yarn'
cache-dependency-path: 'ui/yarn.lock'

- name: Build UI
run: |
CONSUL_VERSION=${{ needs.get-product-version.outputs.product-version }}
CONSUL_VERSION=${{ needs.set-product-version.outputs.product-version }}
CONSUL_BINARY_TYPE=${CONSUL_BINARY_TYPE}
CONSUL_COPYRIGHT_YEAR=$(git show -s --format=%cd --date=format:%Y HEAD)
echo "consul_version is ${CONSUL_VERSION}"
Expand All @@ -202,37 +201,38 @@ jobs:
cd ui && make && cd ..
rm -rf agent/uiserver/dist
mv ui/packages/consul-ui/dist agent/uiserver/

- name: Build
- name: Go Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOLDFLAGS: "${{ needs.get-product-version.outputs.shared-ldflags }}"
run: |
mkdir dist out
go build -ldflags="$GOLDFLAGS" -tags netcgo -o dist/ .
zip -r -j out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip dist/

- uses: actions/upload-artifact@v2
PRODUCT_VERSION: ${{ needs.set-product-version.outputs.product-version }}
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.pre-version }}
CGO_ENABLED: "0"
GOLDFLAGS: "${{needs.set-product-version.outputs.shared-ldflags}}"
uses: hashicorp/actions-go-build@v0.1.7
with:
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
path: out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
go_version: ${{ matrix.go }}
os: ${{ matrix.goos }}
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
go build -ldflags="$GOLDFLAGS" -tags netcgo -o "$BIN_PATH" -trimpath -buildvcs=false

build-docker:
name: Docker ${{ matrix.arch }} build
needs:
- get-product-version
- set-product-version
- build
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["386", "amd64", "arm", "arm64"]
env:
repo: ${{github.event.repository.name}}
version: ${{needs.get-product-version.outputs.product-version}}
version: ${{needs.set-product-version.outputs.product-version}}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# Strip everything but MAJOR.MINOR from the version string and add a `-dev` suffix
# This naming convention will be used ONLY for per-commit dev images
Expand All @@ -258,15 +258,15 @@ jobs:
build-docker-ubi-redhat:
name: Docker Build UBI Image for RedHat Registry
needs:
- get-product-version
- set-product-version
- build
runs-on: ubuntu-latest
env:
repo: ${{github.event.repository.name}}
version: ${{needs.get-product-version.outputs.product-version}}
version: ${{needs.set-product-version.outputs.product-version}}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: hashicorp/actions-docker-build@v1
with:
version: ${{env.version}}
Expand All @@ -278,15 +278,15 @@ jobs:
build-docker-ubi-dockerhub:
name: Docker Build UBI Image for DockerHub
needs:
- get-product-version
- set-product-version
- build
runs-on: ubuntu-latest
env:
repo: ${{github.event.repository.name}}
version: ${{needs.get-product-version.outputs.product-version}}
version: ${{needs.set-product-version.outputs.product-version}}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# Strip everything but MAJOR.MINOR from the version string and add a `-dev` suffix
# This naming convention will be used ONLY for per-commit dev images
Expand All @@ -310,20 +310,20 @@ jobs:

verify-linux:
needs:
- get-product-version
- set-product-version
- build
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["386", "amd64", "arm", "arm64"]
fail-fast: true
env:
version: ${{ needs.get-product-version.outputs.product-version }}
zip_name: consul_${{ needs.get-product-version.outputs.product-version }}_linux_${{ matrix.arch }}.zip
version: ${{ needs.set-product-version.outputs.product-version }}
zip_name: consul_${{ needs.set-product-version.outputs.product-version }}_linux_${{ matrix.arch }}.zip

name: Verify ${{ matrix.arch }} linux binary
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Download ${{ matrix.arch }} zip
uses: actions/download-artifact@v3
Expand All @@ -342,18 +342,18 @@ jobs:

verify-darwin:
needs:
- get-product-version
- set-product-version
- build-darwin
runs-on: macos-latest
strategy:
fail-fast: true
env:
version: ${{needs.get-product-version.outputs.product-version}}
zip_name: consul_${{ needs.get-product-version.outputs.product-version }}_darwin_amd64.zip
version: ${{needs.set-product-version.outputs.product-version}}
zip_name: consul_${{ needs.set-product-version.outputs.product-version }}_darwin_amd64.zip

name: Verify amd64 darwin binary
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Download amd64 darwin zip
uses: actions/download-artifact@v3
Expand All @@ -369,22 +369,22 @@ jobs:
verify-linux-packages-deb:
needs:
- build
- get-product-version
- set-product-version
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["i386", "amd64", "armhf", "arm64"]
# fail-fast: true
env:
version: ${{ needs.get-product-version.outputs.product-version }}
version: ${{ needs.set-product-version.outputs.product-version }}

name: Verify ${{ matrix.arch }} debian package
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set package version
run: |
echo "pkg_version=$(echo ${{ needs.get-product-version.outputs.product-version }} | sed 's/\-/~/g')" >> $GITHUB_ENV
echo "pkg_version=$(echo ${{ needs.set-product-version.outputs.product-version }} | sed 's/\-/~/g')" >> $GITHUB_ENV

- name: Set package name
run: |
Expand All @@ -406,22 +406,22 @@ jobs:
verify-linux-packages-rpm:
needs:
- build
- get-product-version
- set-product-version
runs-on: ubuntu-latest
strategy:
matrix:
# TODO(eculver): re-enable when there is a smaller verification container available
arch: ["i386", "x86_64"] #, "armv7hl", "aarch64"]
env:
version: ${{ needs.get-product-version.outputs.product-version }}
version: ${{ needs.set-product-version.outputs.product-version }}

name: Verify ${{ matrix.arch }} rpm
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set package version
run: |
echo "pkg_version=$(echo ${{ needs.get-product-version.outputs.product-version }} | sed 's/\-/~/g')" >> $GITHUB_ENV
echo "pkg_version=$(echo ${{ needs.set-product-version.outputs.product-version }} | sed 's/\-/~/g')" >> $GITHUB_ENV

- name: Set package name
run: |
Expand Down
Loading