mirror of https://github.com/hashicorp/boundary
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
308 lines
11 KiB
308 lines
11 KiB
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@v3
|
|
- name: Setup go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: "1.18.3"
|
|
- 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@v3
|
|
- 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@v3
|
|
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@v3
|
|
- 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\'""
|
|
|
|
get-product-edition:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
product-edition: ${{ steps.get-product-edition.outputs.product-edition}}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: "1.18.3"
|
|
- name: Get product edition
|
|
id: get-product-edition
|
|
run: |
|
|
make edition
|
|
echo "::set-output name=product-edition::$(make edition)"
|
|
|
|
|
|
build-other:
|
|
needs:
|
|
- get-product-version
|
|
- get-product-edition
|
|
- set-ld-flags
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
goos: [ freebsd, windows, netbsd, openbsd, solaris ]
|
|
goarch: [ "386", "amd64", "arm" ]
|
|
go: [ "1.18.3" ]
|
|
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@v3
|
|
- name: Setup go
|
|
uses: actions/setup-go@v3
|
|
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: Set sha
|
|
id: set-sha
|
|
run: echo "::set-output name=sha::$(head -n1 internal/ui/VERSION | cut -d ' ' -f1)"
|
|
- name: Download UI artifact
|
|
uses: dawidd6/action-download-artifact@v2
|
|
with:
|
|
workflow: build-admin-ui.yaml
|
|
commit: ${{ steps.set-sha.outputs.sha }}
|
|
repo: "hashicorp/boundary-ui"
|
|
name: admin-ui-${{ needs.get-product-edition.outputs.product-edition }}
|
|
path: internal/ui/.tmp/boundary-ui/ui/admin/dist
|
|
- name: Go Build
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: 0
|
|
run: |
|
|
mkdir -p dist out
|
|
unset GOPATH;
|
|
# Build plugins
|
|
./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@v3
|
|
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
|
|
- get-product-edition
|
|
- set-ld-flags
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
goos: [linux]
|
|
goarch: ["arm", "arm64", "386", "amd64"]
|
|
go: [ "1.18.3" ]
|
|
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@v3
|
|
- 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@v3
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
- name: Set sha
|
|
id: set-sha
|
|
run: echo "::set-output name=sha::$(head -n1 internal/ui/VERSION | cut -d ' ' -f1)"
|
|
- name: Download UI artifact
|
|
uses: dawidd6/action-download-artifact@v2
|
|
with:
|
|
workflow: build-admin-ui.yaml
|
|
commit: ${{ steps.set-sha.outputs.sha }}
|
|
repo: "hashicorp/boundary-ui"
|
|
name: admin-ui-${{ needs.get-product-edition.outputs.product-edition }}
|
|
path: internal/ui/.tmp/boundary-ui/ui/admin/dist
|
|
- name: Go Build
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: 0
|
|
run: |
|
|
mkdir -p dist out
|
|
unset GOPATH;
|
|
# Build plugins
|
|
./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@v3
|
|
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@v3
|
|
with:
|
|
name: ${{ env.RPM_PACKAGE }}
|
|
path: out/${{ env.RPM_PACKAGE }}
|
|
- uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ env.DEB_PACKAGE }}
|
|
path: out/${{ env.DEB_PACKAGE }}
|
|
|
|
|
|
build-darwin:
|
|
needs:
|
|
- get-product-version
|
|
- get-product-edition
|
|
- set-ld-flags
|
|
runs-on: macos-latest
|
|
strategy:
|
|
matrix:
|
|
goos: [ darwin ]
|
|
goarch: [ "amd64", "arm64" ]
|
|
go: [ "1.18.3" ]
|
|
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@v3
|
|
- name: Setup go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: ${{ matrix.go }}
|
|
- name: Set sha
|
|
id: set-sha
|
|
run: echo "::set-output name=sha::$(head -n1 internal/ui/VERSION | cut -d ' ' -f1)"
|
|
- name: Download UI artifact
|
|
uses: dawidd6/action-download-artifact@v2
|
|
with:
|
|
workflow: build-admin-ui.yaml
|
|
commit: ${{ steps.set-sha.outputs.sha }}
|
|
repo: "hashicorp/boundary-ui"
|
|
name: admin-ui-${{ needs.get-product-edition.outputs.product-edition }}
|
|
path: internal/ui/.tmp/boundary-ui/ui/admin/dist
|
|
- name: Go Build
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: 0
|
|
run: |
|
|
mkdir -p dist out
|
|
unset GOPATH;
|
|
# Build plugins
|
|
./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@v3
|
|
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@v3
|
|
- name: Replace + in version
|
|
run: |
|
|
echo "dockerversion=$(echo ${{ needs.get-product-version.outputs.product-version }} | sed 's/+ent/-ent/g')" >> $GITHUB_ENV
|
|
- name: Docker Build (Action)
|
|
uses: hashicorp/actions-docker-build@v1
|
|
with:
|
|
version: ${{ env.dockerversion }}
|
|
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.dockerversion }}
|
|
public.ecr.aws/hashicorp/${{ env.repo }}:${{ env.dockerversion }}
|