Skip to content

Merge branch 'main' into release/v2.7.0 #246

Merge branch 'main' into release/v2.7.0

Merge branch 'main' into release/v2.7.0 #246

Workflow file for this run

name: build
on:
push:
branches:
- main
- release/**
workflow_dispatch:
env:
PKG_NAME: 'hcp-terraform-operator'
PKG_PATH: 'github.com/hashicorp/hcp-terraform-operator'
DOCKER_HUB_REPO: 'hashicorp/hcp-terraform-operator'
DOCKER_HUB_DEV_REPO: 'hashicorppreview/hcp-terraform-operator'
jobs:
set-product-version:
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.set-product-version.outputs.product-version }}
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Set product version
id: set-product-version
uses: hashicorp/actions-set-product-version@d9b52fb778068099ca4c5e28e1ca0fee2544e114 # v2
generate-metadata-file:
needs: set-product-version
runs-on: ubuntu-latest
env:
METADATA_FILE_NAME: 'metadata.json'
outputs:
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Generate metadata file
id: generate-metadata-file
uses: hashicorp/actions-generate-metadata@fdbc8803a0e53bcbb912ddeee3808329033d6357 # v1.1.1
with:
version: ${{ needs.set-product-version.outputs.product-version }}
product: ${{ env.PKG_NAME }}
repositoryOwner: 'hashicorp'
metadataFileName: ${{ env.METADATA_FILE_NAME }}
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: metadata.json
path: ${{ env.METADATA_FILE_NAME }}
build:
name: Go Linux ${{ matrix.arch }} build
needs: [set-product-version]
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.set-up-go.outputs.go-version }}
strategy:
matrix:
arch: ["amd64", "arm64"]
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Setup Go
id: set-up-go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: 'go.mod'
- name: Go build
uses: hashicorp/actions-go-build@37358f6098ef21b09542d84a9814ebb843aa4e3e # v1
env:
CGO_ENABLED: 0
LD_FLAGS: "-X '${{ env.PKG_PATH }}/version.Version=${{ needs.set-product-version.outputs.product-version }}'"
with:
product_name: ${{ env.PKG_NAME }}
product_version: ${{ needs.set-product-version.outputs.product-version }}
bin_name: ${{ vars.BIN_NAME }}
go_version: ${{ steps.set-up-go.outputs.go-version }}
os: linux
arch: ${{ matrix.arch }}
reproducible: report
instructions: |
go build -a -ldflags="${{ env.LD_FLAGS }}" -trimpath -o $BIN_PATH main.go
build-docker:
name: Docker ${{ matrix.arch }} build
needs: [build, set-product-version]
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["amd64", "arm64"]
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Docker build
uses: hashicorp/actions-docker-build@11d43ef520c65f58683d048ce9b47d6617893c9a # v2
env:
VERSION: ${{ needs.set-product-version.outputs.product-version }}
GO_VERSION: ${{ needs.build.outputs.go-version }}
with:
version: ${{ env.VERSION }}
bin_name: ${{ vars.BIN_NAME }}
target: release-default
arch: ${{ matrix.arch }}
tags: |
docker.io/${{ env.DOCKER_HUB_REPO }}:${{ env.VERSION }}
dev_tags: |
docker.io/${{ env.DOCKER_HUB_DEV_REPO }}:${{ env.VERSION }}
docker.io/${{ env.DOCKER_HUB_DEV_REPO }}:${{ env.VERSION }}-${{ github.sha }}
build-docker-ubi:
name: Docker build UBI
needs: [build, set-product-version]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Docker build
uses: hashicorp/actions-docker-build@11d43ef520c65f58683d048ce9b47d6617893c9a # v2
env:
VERSION: ${{ needs.set-product-version.outputs.product-version }}
GO_VERSION: ${{ needs.build.outputs.go-version }}
with:
version: ${{ env.VERSION }}
bin_name: ${{ vars.BIN_NAME }}
target: release-ubi
arch: amd64
tags: |
docker.io/${{ env.DOCKER_HUB_REPO }}:${{ env.VERSION }}-ubi
dev_tags: |
docker.io/${{ env.DOCKER_HUB_DEV_REPO }}:${{ env.VERSION }}-ubi
docker.io/${{ env.DOCKER_HUB_DEV_REPO }}:${{ env.VERSION }}-ubi-${{ github.sha }}
redhat_tag: quay.io/redhat-isv-containers/671273c6fbc31c69e20237c0:${{ env.VERSION }}