Files
threshold/.github/workflows/build.yml
T
Timothy Messier 8557442370 ci: Add plugin compile step (#1840)
Some OS build steps were not compiling the plugins before compiling the
boundary binary. This resulted in binaries that did not have plugins
included, and would result in an error when starting a boundary server.
2022-02-02 17:29:29 -05:00

319 lines
11 KiB
YAML

name: build
on:
push:
# Sequence of patterns matched against refs/heads
branches:
# Push events on main branch
- 'main'
env:
PKG_NAME: "boundary"
jobs:
get-product-version:
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.get-product-version.outputs.product-version }}
steps:
- uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: "1.17.5"
- name: get product version
id: get-product-version
run: |
make version
echo "::set-output name=product-version::$(make 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
uses: hashicorp/actions-generate-metadata@main
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 }}
set-ld-flags:
needs: get-product-version
runs-on: ubuntu-latest
outputs:
ldflags: ${{ steps.generate-ld-flags.outputs.ldflags }}
steps:
- uses: actions/checkout@v2
- name: 'Generate ld flags'
id: generate-ld-flags
run: |
project="$(go list -m)"
sha="$(git rev-parse HEAD)"
echo "::set-output name=ldflags::"-s -w -X \'$project/version.GitCommit=$sha\'""
build-other:
needs:
- get-product-version
- set-ld-flags
runs-on: ubuntu-latest
strategy:
matrix:
goos: [ freebsd, windows, netbsd, openbsd, solaris ]
goarch: [ "386", "amd64", "arm" ]
go: [ "1.17.5" ]
exclude:
- goos: solaris
goarch: 386
- goos: solaris
goarch: arm
- goos: windows
goarch: arm
fail-fast: true
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
env:
GOPRIVATE: "github.com/hashicorp"
GO111MODULE: on
LD_FLAGS: ${{ needs.set-ld-flags.outputs.ldflags }}
steps:
- uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Setup Git
run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
- name: Setup node and yarn
uses: actions/setup-node@v2
with:
node-version: '14'
cache-dependency-path: 'ui/yarn.lock'
- name: Install Yarn
run: |
npm install -g yarn
- name: UI Build
run: |
SHA="$(head -n1 internal/ui/VERSION | cut -d ' ' -f1)"
DIR=internal/ui/.tmp/boundary-ui
mkdir -p "$(dirname "$DIR")"
git clone https://github.com/hashicorp/boundary-ui "$DIR"
cd "$DIR"
git fetch origin "$SHA"
git checkout "$SHA"
yarn install
yarn build:ui:admin
- name: Go Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
mkdir -p dist out
unset GOPATH;
# Build plugins
sh ./scripts/plugins.sh
go build -v -tags "ui" -ldflags "${{ env.LD_FLAGS }}" -o dist/ ./cmd/boundary
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-linux:
needs:
- get-product-version
- set-ld-flags
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux]
goarch: ["arm", "arm64", "386", "amd64"]
go: [ "1.17.5" ]
fail-fast: true
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
env:
GOPRIVATE: "github.com/hashicorp"
GO111MODULE: on
LD_FLAGS: ${{ needs.set-ld-flags.outputs.ldflags }}
steps:
- uses: actions/checkout@v2
- name: Setup Git
run: git config --global url."https://${{ secrets.ELEVATED_GITHUB_TOKEN }}:@github.com".insteadOf "https://github.com"
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Setup node and yarn
uses: actions/setup-node@v2
with:
node-version: '14'
cache-dependency-path: 'ui/yarn.lock'
- name: Install Yarn
run: |
npm install -g yarn
- name: UI Build
run: |
SHA="$(head -n1 internal/ui/VERSION | cut -d ' ' -f1)"
DIR=internal/ui/.tmp/boundary-ui
mkdir -p "$(dirname "$DIR")"
git clone https://github.com/hashicorp/boundary-ui "$DIR"
cd "$DIR"
git fetch origin "$SHA"
git checkout "$SHA"
yarn install
yarn build:ui:admin
- name: Go Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
mkdir -p dist out
unset GOPATH;
# Build plugins
sh ./scripts/plugins.sh
go build -v -tags "ui" -ldflags "${{ env.LD_FLAGS }}" -o dist/ ./cmd/boundary
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: Linux Packaging
uses: hashicorp/actions-packaging-linux@v1
with:
name: ${{ github.event.repository.name }}
description: "HashiCorp Boundary - Identity-based access management for dynamic infrastructure"
arch: ${{ matrix.goarch }}
version: ${{ needs.get-product-version.outputs.product-version }}
maintainer: "HashiCorp"
homepage: "https://github.com/hashicorp/boundary"
license: "MPL-2.0"
binary: "dist/${{ env.PKG_NAME }}"
deb_depends: "openssl"
rpm_depends: "openssl"
config_dir: ".release/linux/package/"
preinstall: ".release/linux/preinst"
postremove: ".release/linux/postrm"
- name: Add Linux Package names to env
run: |
echo "RPM_PACKAGE=$(basename out/*.rpm)" >> $GITHUB_ENV
echo "DEB_PACKAGE=$(basename out/*.deb)" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
with:
name: ${{ env.RPM_PACKAGE }}
path: out/${{ env.RPM_PACKAGE }}
- uses: actions/upload-artifact@v2
with:
name: ${{ env.DEB_PACKAGE }}
path: out/${{ env.DEB_PACKAGE }}
build-darwin:
needs:
- get-product-version
- set-ld-flags
runs-on: macos-latest
strategy:
matrix:
goos: [ darwin ]
goarch: [ "amd64", "arm64" ]
go: [ "1.17.5" ]
fail-fast: true
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
env:
GOPRIVATE: "github.com/hashicorp"
GO111MODULE: on
LD_FLAGS: ${{ needs.set-ld-flags.outputs.ldflags }}
steps:
- uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Setup node and yarn
uses: actions/setup-node@v2
with:
node-version: '14'
cache-dependency-path: 'ui/yarn.lock'
- name: Install Yarn
run: |
npm install -g yarn
- name: UI Build
run: |
SHA="$(head -n1 internal/ui/VERSION | cut -d ' ' -f1)"
DIR=internal/ui/.tmp/boundary-ui
mkdir -p "$(dirname "$DIR")"
git clone https://github.com/hashicorp/boundary-ui "$DIR"
cd "$DIR"
git fetch origin "$SHA"
git checkout "$SHA"
yarn install
yarn build:ui:admin
- name: Go Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
mkdir -p dist out
unset GOPATH;
# Build plugins
sh ./scripts/plugins.sh
go build -v -tags "ui netcgo" -ldflags "${{ env.LD_FLAGS }}" -o dist/ ./cmd/boundary
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-linux
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["arm", "arm64", "386", "amd64"]
env:
repo: ${{ github.event.repository.name }}
version: ${{ needs.get-product-version.outputs.product-version }}
steps:
- uses: actions/checkout@v2
- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: docker.artifactory.hashicorp.engineering
username: ${{ secrets.ARTIFACTORY_RO_USER }}
password: ${{ secrets.ARTIFACTORY_RO_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
image: docker.artifactory.hashicorp.engineering/prodsec-binfmt:latest
- name: Docker Build (Action)
uses: hashicorp/actions-docker-build@v1
with:
version: ${{ env.version }}
target: default
arch: ${{ matrix.arch }}
zip_artifact_name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_linux_${{ matrix.arch }}.zip
tags: |
docker.io/hashicorp/${{ env.repo }}:${{ env.version }}
public.ecr.aws/hashicorp/${{ env.repo }}:${{ env.version }}