2021-10-26 06:01:18 +00:00
name : build
on :
push :
# Sequence of patterns matched against refs/heads
2022-01-06 19:32:35 +00:00
branches :
# Push events on the main branch
- main
2021-10-29 05:22:38 +00:00
2021-10-26 06:01:18 +00:00
env :
PKG_NAME : consul
jobs :
get-product-version :
runs-on : ubuntu-latest
outputs :
product-version : ${{ steps.get-product-version.outputs.product-version }}
pre-version : ${{ steps.get-product-version.outputs.pre-version }}
pkg-version : ${{ steps.get-product-version.outputs.pkg-version }}
shared-ldflags : ${{ steps.shared-ldflags.outputs.shared-ldflags }}
steps :
- uses : actions/checkout@v2
- name : get product version
id : get-product-version
run : |
2021-12-15 00:11:16 +00:00
CONSUL_VERSION=$(build-support/scripts/version.sh -r)
## 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}"
2021-10-26 06:01:18 +00:00
echo "::set-output name=pre-version::${PREREL_VERSION}"
echo "::set-output name=pkg-version::${VERSION}"
- name : Set shared -ldflags
id : shared-ldflags
run : echo "::set-output name=shared-ldflags::-X github.com/hashicorp/consul/version.GitCommit=${GITHUB_SHA::8} -X github.com/hashicorp/consul/version.GitDescribe=${{ steps.get-product-version.outputs.product-version }}"
generate-metadata-file :
needs : get-product-version
runs-on : ubuntu-latest
outputs :
filepath : ${{ steps.generate-metadata-file.outputs.filepath }}
steps :
- name : 'Checkout directory'
uses : actions/checkout@v2
- name : Generate metadata file
id : generate-metadata-file
2022-04-22 16:26:12 +00:00
uses : hashicorp/actions-generate-metadata@v1
2021-10-26 06:01:18 +00:00
with :
version : ${{ needs.get-product-version.outputs.product-version }}
product : ${{ env.PKG_NAME }}
- uses : actions/upload-artifact@v2
with :
name : metadata.json
path : ${{ steps.generate-metadata-file.outputs.filepath }}
build :
needs : get-product-version
runs-on : ubuntu-latest
strategy :
matrix :
include :
2022-04-14 20:55:10 +00:00
- {go : "1.18.1" , goos : "linux" , goarch : "386" }
- {go : "1.18.1" , goos : "linux" , goarch : "amd64" }
- {go : "1.18.1" , goos : "linux" , goarch : "arm" }
- {go : "1.18.1" , goos : "linux" , goarch : "arm64" }
- {go : "1.18.1" , goos : "freebsd" , goarch : "386" }
- {go : "1.18.1" , goos : "freebsd" , goarch : "amd64" }
- {go : "1.18.1" , goos : "windows" , goarch : "386" }
- {go : "1.18.1" , goos : "windows" , goarch : "amd64" }
- {go : "1.18.1" , goos : "solaris" , goarch : "amd64" }
2021-10-26 06:01:18 +00:00
fail-fast : true
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 }}
- name : Setup with node and yarn
uses : actions/setup-node@v2
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_BINARY_TYPE=${CONSUL_BINARY_TYPE}
CONSUL_COPYRIGHT_YEAR=$(git show -s --format=%cd --date=format:%Y HEAD)
echo "consul_version is ${CONSUL_VERSION}"
echo "consul binary type is ${CONSUL_BINARY_TYPE}"
echo "consul copyright year is ${CONSUL_COPYRIGHT_YEAR}"
cd ui && make && cd ..
2022-05-31 19:33:56 +00:00
rm -rf agent/uiserver/dist
mv ui/packages/consul-ui/dist agent/uiserver/
2021-10-26 06:01:18 +00:00
- name : 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
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
- name : Package
if : ${{ matrix.goos == 'linux' }}
uses : hashicorp/actions-packaging-linux@v1
with :
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 }}
maintainer : "HashiCorp"
homepage : "https://github.com/hashicorp/consul"
license : "MPL-2.0"
binary : "dist/${{ env.PKG_NAME }}"
deb_depends : "openssl"
rpm_depends : "openssl"
config_dir : ".release/linux/package"
preinstall : ".release/linux/preinstall"
postinstall : ".release/linux/postinstall"
2022-02-01 20:07:18 +00:00
preremove : ".release/linux/preremove"
2021-10-26 06:01:18 +00:00
postremove : ".release/linux/postremove"
- name : Set Package Names
if : ${{ matrix.goos == 'linux' }}
run : |
echo "RPM_PACKAGE=$(basename out/*.rpm)" >> $GITHUB_ENV
echo "DEB_PACKAGE=$(basename out/*.deb)" >> $GITHUB_ENV
- uses : actions/upload-artifact@v2
if : ${{ matrix.goos == 'linux' }}
with :
name : ${{ env.RPM_PACKAGE }}
path : out/${{ env.RPM_PACKAGE }}
- uses : actions/upload-artifact@v2
if : ${{ matrix.goos == 'linux' }}
with :
name : ${{ env.DEB_PACKAGE }}
path : out/${{ env.DEB_PACKAGE }}
build-darwin :
needs : get-product-version
runs-on : macos-latest
strategy :
matrix :
goos : [ darwin ]
2021-12-15 01:46:04 +00:00
goarch : [ "amd64" , "arm64" ]
2022-04-14 20:55:10 +00:00
go : [ "1.18.1" ]
2021-10-26 06:01:18 +00:00
fail-fast : true
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 }}
- name : Setup with node and yarn
uses : actions/setup-node@v2
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_BINARY_TYPE=${CONSUL_BINARY_TYPE}
CONSUL_COPYRIGHT_YEAR=$(git show -s --format=%cd --date=format:%Y HEAD)
echo "consul_version is ${CONSUL_VERSION}"
echo "consul binary type is ${CONSUL_BINARY_TYPE}"
echo "consul copyright year is ${CONSUL_COPYRIGHT_YEAR}"
cd ui && make && cd ..
2022-05-31 19:33:56 +00:00
rm -rf agent/uiserver/dist
mv ui/packages/consul-ui/dist agent/uiserver/
2021-10-26 06:01:18 +00:00
- name : Build
env :
GOOS : ${{ matrix.goos }}
GOARCH : ${{ matrix.goarch }}
GOLDFLAGS : "${{ needs.get-product-version.outputs.shared-ldflags }}"
run : |
mkdir dist out
2022-01-24 22:34:57 +00:00
go build -ldflags="$GOLDFLAGS" -tags netcgo -o dist/ .
2021-10-26 06:01:18 +00:00
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
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
build-docker :
name : Docker ${{ matrix.arch }} build
needs :
- get-product-version
- build
runs-on : ubuntu-latest
strategy :
matrix :
2022-06-06 21:42:11 +00:00
arch : [ "386" , "amd64" , "arm" , "arm64" ]
2021-10-26 06:01:18 +00:00
env :
repo : ${{github.event.repository.name}}
version : ${{needs.get-product-version.outputs.product-version}}
steps :
- uses : actions/checkout@v2
- name : Docker Build (Action)
uses : hashicorp/actions-docker-build@v1
with :
version : ${{env.version}}
target : default
arch : ${{matrix.arch}}
tags : |
docker.io/hashicorp/${{env.repo}}:${{env.version}}
2021-12-15 21:17:16 +00:00
public.ecr.aws/hashicorp/${{env.repo}}:${{env.version}}
2022-05-17 19:23:03 +00:00
dev_tags : |
2022-05-24 22:23:01 +00:00
docker.io/hashicorppreview/${{ env.repo }}:${{ env.version }}
2022-05-17 19:23:03 +00:00
docker.io/hashicorppreview/${{ env.repo }}:${{ env.version }}-${{ github.sha }}
2022-06-06 21:42:11 +00:00
smoke_test : .github/scripts/verify_docker.sh v${{ env.version }}
2022-05-26 16:49:47 +00:00
build-docker-redhat :
name : Docker Build UBI Image for RedHat
needs :
- get-product-version
- build
runs-on : ubuntu-latest
env :
repo : ${{github.event.repository.name}}
version : ${{needs.get-product-version.outputs.product-version}}
steps :
- uses : actions/checkout@v2
- uses : hashicorp/actions-docker-build@v1
with :
version : ${{env.version}}
target : ubi
arch : amd64
2022-05-27 18:50:41 +00:00
redhat_tag : scan.connect.redhat.com/ospid-612d01d49f14588c41ebf67c/${{env.repo}}:${{env.version}}-ubi
2022-06-06 21:42:11 +00:00
smoke_test : .github/scripts/verify_docker.sh v${{ env.version }}
verify-linux :
2022-05-27 18:50:41 +00:00
needs :
- get-product-version
- build
runs-on : ubuntu-latest
strategy :
matrix :
2022-06-06 21:42:11 +00:00
arch : [ "386" , "amd64" , "arm" , "arm64" ]
2022-05-27 18:50:41 +00:00
fail-fast : true
env :
2022-06-06 21:42:11 +00:00
version : ${{ needs.get-product-version.outputs.product-version }}
zip_name : consul_${{ needs.get-product-version.outputs.product-version }}_linux_${{ matrix.arch }}.zip
name : Verify ${{ matrix.arch }} linux binary
2022-05-27 18:50:41 +00:00
steps :
- uses : actions/checkout@v2
2022-06-06 21:42:11 +00:00
- name : Download ${{ matrix.arch }} zip
uses : actions/download-artifact@v3
2022-05-27 18:50:41 +00:00
with :
2022-06-06 21:42:11 +00:00
name : ${{ env.zip_name }}
- name : Set up QEMU
uses : docker/setup-qemu-action@v1
if : ${{ matrix.arch == 'arm' || matrix.arch == 'arm64' }}
with :
# this should be a comma-separated string as opposed to an array
platforms : arm,arm64
- name : Run verification for ${{ matrix.arch }} binary
run : .github/scripts/verify_artifact.sh ${{ env.zip_name }} v${{ env.version }}
2022-05-27 18:50:41 +00:00
verify-darwin :
needs :
- get-product-version
- build-darwin
runs-on : macos-latest
strategy :
fail-fast : true
env :
version : ${{needs.get-product-version.outputs.product-version}}
2022-06-06 21:42:11 +00:00
zip_name : consul_${{ needs.get-product-version.outputs.product-version }}_darwin_amd64.zip
name : Verify amd64 darwin binary
2022-05-27 18:50:41 +00:00
steps :
- uses : actions/checkout@v2
2022-06-06 21:42:11 +00:00
- name : Download amd64 darwin zip
uses : actions/download-artifact@v3
2022-05-27 18:50:41 +00:00
with :
2022-06-06 21:42:11 +00:00
name : ${{ env.zip_name }}
- name : Unzip amd64 darwin zip
run : unzip ${{ env.zip_name }}
- name : Run verification for amd64 darwin binary
run : .github/scripts/verify_bin.sh ./consul v${{ env.version }}
2022-05-27 18:50:41 +00:00
verify-linux-packages-deb :
2022-06-06 21:42:11 +00:00
needs :
- build
- get-product-version
2022-05-27 18:50:41 +00:00
runs-on : ubuntu-latest
strategy :
matrix :
2022-06-06 21:42:11 +00:00
arch : [ "i386" , "amd64" , "arm" , "arm64" ]
# fail-fast: true
env :
version : ${{ needs.get-product-version.outputs.product-version }}
2022-05-27 18:50:41 +00:00
name : Verify ${{ matrix.arch }} debian package
steps :
- uses : actions/checkout@v2
2022-06-06 21:42:11 +00:00
- name : Set package version
run : |
echo "pkg_version=$(echo ${{ needs.get-product-version.outputs.product-version }} | sed 's/\-/~/g')" >> $GITHUB_ENV
2022-05-27 18:50:41 +00:00
2022-06-06 21:42:11 +00:00
- name : Set package name
2022-05-27 18:50:41 +00:00
run : |
2022-06-06 21:42:11 +00:00
echo "pkg_name=consul_${{ env.pkg_version }}-1_${{ matrix.arch }}.deb" >> $GITHUB_ENV
- name : Download workflow artifacts
uses : actions/download-artifact@v3
with :
name : ${{ env.pkg_name }}
- name : Set up QEMU
uses : docker/setup-qemu-action@v1
with :
platforms : all
2022-05-27 18:50:41 +00:00
- name : Verify ${{ matrix.arch }} debian package
2022-06-06 21:42:11 +00:00
run : ./.github/scripts/verify_artifact.sh ${{ env.pkg_name }} v${{ env.version }}
2022-05-27 18:50:41 +00:00
verify-linux-packages-rpm :
2022-06-06 21:42:11 +00:00
needs :
- build
- get-product-version
2022-05-27 18:50:41 +00:00
runs-on : ubuntu-latest
strategy :
matrix :
2022-06-06 21:42:11 +00:00
arch : [ "i386" , "x86_64" , "arm" , "aarch64" ]
# fail-fast: true
env :
version : ${{ needs.get-product-version.outputs.product-version }}
2022-05-27 18:50:41 +00:00
2022-06-06 21:42:11 +00:00
name : Verify ${{ matrix.arch }} rpm
2022-05-27 18:50:41 +00:00
steps :
- uses : actions/checkout@v2
2022-06-06 21:42:11 +00:00
- name : Set package version
2022-05-27 18:50:41 +00:00
run : |
2022-06-06 21:42:11 +00:00
echo "pkg_version=$(echo ${{ needs.get-product-version.outputs.product-version }} | sed 's/\-/~/g')" >> $GITHUB_ENV
2022-05-27 18:50:41 +00:00
2022-06-06 21:42:11 +00:00
- name : Set package name
2022-05-27 18:50:41 +00:00
run : |
2022-06-06 21:42:11 +00:00
echo "pkg_name=consul-${{ env.pkg_version }}-1.${{ matrix.arch }}.rpm" >> $GITHUB_ENV
- name : Download workflow artifacts
uses : actions/download-artifact@v3
with :
name : ${{ env.pkg_name }}
- name : Set up QEMU
uses : docker/setup-qemu-action@v1
with :
platforms : all
- name : Verify ${{ matrix.arch }} rpm
run : ./.github/scripts/verify_artifact.sh ${{ env.pkg_name }} v${{ env.version }}