Add artifacts manifest (automatically generated) (#199) #464
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
workflow_dispatch: | |
pull_request: | |
# The default types for pull_request are [ opened, synchronize, reopened ]. | |
# This is insufficient for our needs, since we're skipping stuff on PRs in | |
# draft mode. By adding the ready_for_review type, when a draft pr is marked | |
# ready, we run everything, including the stuff we'd have skipped up until now. | |
types: [opened, synchronize, reopened, ready_for_review] | |
push: | |
branches: | |
- main | |
# Prevent multiple builds from running concurrently | |
concurrency: | |
group: ${{ github.head_ref || github.run_id }}-build | |
cancel-in-progress: true | |
env: | |
PKG_NAME: "vault-benchmark" | |
METADATA: "" | |
jobs: | |
get-go-version: | |
name: "Determine Go toolchain version" | |
runs-on: ubuntu-latest | |
outputs: | |
go-version: ${{ steps.get-go-version.outputs.go-version }} | |
steps: | |
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
- name: Determine Go version | |
id: get-go-version | |
# We use .go-version as our source of truth for current Go | |
# version, because "goenv" can react to it automatically. | |
run: | | |
echo "Building with Go $(cat .go-version)" | |
echo "go-version=$(cat .go-version)" >> $GITHUB_OUTPUT | |
set-product-version: | |
runs-on: ubuntu-latest | |
outputs: | |
product-version: ${{ steps.set-product-version.outputs.product-version }} | |
product-base-version: ${{ steps.set-product-version.outputs.base-product-version }} | |
product-prerelease-version: ${{ steps.set-product-version.outputs.prerelease-product-version }} | |
steps: | |
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
- name: Set Product version | |
id: set-product-version | |
uses: hashicorp/actions-set-product-version@v1 | |
generate-metadata-file: | |
needs: set-product-version | |
runs-on: ubuntu-latest | |
outputs: | |
filepath: ${{ steps.generate-metadata-file.outputs.filepath }} | |
steps: | |
- name: "Checkout directory" | |
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
- name: Generate metadata file | |
id: generate-metadata-file | |
uses: hashicorp/actions-generate-metadata@v1 | |
with: | |
version: ${{ needs.set-product-version.outputs.product-version }} | |
product: ${{ env.PKG_NAME }} | |
repositoryOwner: "hashicorp" | |
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | |
with: | |
name: metadata.json | |
path: ${{ steps.generate-metadata-file.outputs.filepath }} | |
build-other: | |
needs: | |
- get-go-version | |
- set-product-version | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
goos: [freebsd, windows, netbsd, openbsd, solaris] | |
goarch: ["386", "amd64", "arm"] | |
exclude: | |
- goos: solaris | |
goarch: 386 | |
- goos: solaris | |
goarch: arm | |
- goos: windows | |
goarch: arm | |
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build | |
steps: | |
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
- uses: hashicorp/[email protected] | |
env: | |
BASE_VERSION: ${{ needs.set-product-version.outputs.product-base-version }} | |
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.product-prerelease-version}} | |
METADATA_VERSION: ${{ env.METADATA }} | |
with: | |
product_name: ${{ env.PKG_NAME }} | |
product_version: ${{ needs.set-product-version.outputs.product-version }} | |
go_version: ${{ needs.get-go-version.outputs.go-version }} | |
os: ${{ matrix.goos }} | |
arch: ${{ matrix.goarch }} | |
reproducible: assert | |
instructions: | | |
make build | |
build-linux: | |
needs: | |
- get-go-version | |
- set-product-version | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [linux] | |
goarch: ["arm", "arm64", "386", "amd64"] | |
fail-fast: true | |
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build | |
steps: | |
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
- uses: hashicorp/[email protected] | |
env: | |
BASE_VERSION: ${{ needs.set-product-version.outputs.product-base-version }} | |
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.product-prerelease-version}} | |
METADATA_VERSION: ${{ env.METADATA }} | |
with: | |
product_name: ${{ env.PKG_NAME }} | |
product_version: ${{ needs.set-product-version.outputs.product-version }} | |
go_version: ${{ needs.get-go-version.outputs.go-version }} | |
os: ${{ matrix.goos }} | |
arch: ${{ matrix.goarch }} | |
reproducible: assert | |
instructions: | | |
make build | |
- name: Copy license file to config_dir | |
if: ${{ matrix.goos == 'linux' }} | |
env: | |
LICENSE_DIR: ".release/linux/package/usr/share/doc/${{ env.PKG_NAME }}" | |
run: | | |
mkdir -p "$LICENSE_DIR" && cp LICENSE "$LICENSE_DIR/LICENSE.txt" | |
- name: Package | |
if: ${{ matrix.goos == 'linux' }} | |
uses: hashicorp/actions-packaging-linux@v1 | |
with: | |
name: ${{ github.event.repository.name }} | |
description: "vault-benchmark is a template repo for oss products." | |
arch: ${{ matrix.goarch }} | |
version: ${{ needs.set-product-version.outputs.product-version }} | |
maintainer: "HashiCorp" | |
homepage: "https://github.com/hashicorp/vault-benchmark" | |
license: "MPL-2.0" | |
binary: "dist/${{ env.PKG_NAME }}" | |
deb_depends: "openssl" | |
rpm_depends: "openssl" | |
config_dir: ".release/linux/package/" | |
- 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@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | |
if: ${{ matrix.goos == 'linux' }} | |
with: | |
name: ${{ env.RPM_PACKAGE }} | |
path: out/${{ env.RPM_PACKAGE }} | |
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | |
if: ${{ matrix.goos == 'linux' }} | |
with: | |
name: ${{ env.DEB_PACKAGE }} | |
path: out/${{ env.DEB_PACKAGE }} | |
build-darwin: | |
needs: | |
- get-go-version | |
- set-product-version | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
goos: [darwin] | |
goarch: ["amd64", "arm64"] | |
fail-fast: true | |
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
steps: | |
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
- uses: hashicorp/[email protected] | |
env: | |
BASE_VERSION: ${{ needs.set-product-version.outputs.product-base-version }} | |
PRERELEASE_VERSION: ${{ needs.set-product-version.outputs.product-prerelease-version}} | |
METADATA_VERSION: ${{ env.METADATA }} | |
with: | |
product_name: ${{ env.PKG_NAME }} | |
product_version: ${{ needs.set-product-version.outputs.product-version }} | |
go_version: ${{ needs.get-go-version.outputs.go-version }} | |
os: ${{ matrix.goos }} | |
arch: ${{ matrix.goarch }} | |
reproducible: assert | |
instructions: | | |
make build | |
build-docker-default: | |
name: Docker ${{ matrix.arch }} default release build | |
needs: | |
- set-product-version | |
- build-linux | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: ["arm", "arm64", "386", "amd64"] | |
env: | |
repo: ${{ github.event.repository.name }} | |
version: ${{ needs.set-product-version.outputs.product-version }} | |
steps: | |
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
- name: Docker Build (Action) | |
uses: hashicorp/actions-docker-build@v1 | |
with: | |
version: ${{ env.version }} | |
target: release-default | |
arch: ${{ matrix.arch }} | |
instructions: | | |
make image | |
# The ECR tag used below is to allow us to test by pushing to a private ECR registry. | |
# If you want to pubish to ECR use the following syntax instead - public.ecr.aws/hashicorp/${{env.repo}}:${{env.version}}. | |
# Please note - if you haven't previously been publishing to ECR you will need to reach out to team-rel-eng | |
# - https://hashicorp.atlassian.net/wiki/spaces/RDXPOC/pages/2298218311/How+to+Push+a+Docker+image+to+ECR | |
tags: | | |
docker.io/hashicorp/${{ env.repo }}:${{ env.version }} | |
public.ecr.aws/hashicorp/${{ env.repo }}:${{ env.version }} | |
# dev_tags are tags that get automatically pushed whenever successful | |
# builds make it to the stable channel. The intention is for these tags | |
# to be used for early testing of new code prior to official releases | |
# going out. The stable channel implies that all tests and scans have | |
# completed successfully, so these images should be _stable_ but are not | |
# intended for production use. | |
# | |
# Here we have two example dev tags. The first (ending -dev) is a tag | |
# that will be updated over-and-over as new builds arrive in stable. | |
# | |
# The second (using the git SHA) will produce a new separate tag for | |
# each commit that is built. (These can still be overridden if the same | |
# commit is built successfully a second time, but that is a less likely | |
# scenario.) These kinds of dev tags are useful if you want to be able | |
# to use Docker images built from those specific commits. | |
# | |
# NOTE: dev_tags MUST publish to the 'hashicorppreview' DockerHub org, it | |
# will fail to any other DockerHub org or registry. You can optionally | |
# prepend docker.io | |
dev_tags: | | |
docker.io/hashicorppreview/${{ env.repo }}:${{ env.version }}-dev | |
docker.io/hashicorppreview/${{ env.repo }}:${{ env.version }}-${{ github.sha }} | |