fix me 4 #12
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, push] | |
env: | |
PKG_NAME: "http-echo" | |
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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
with: | |
# This is the minimum required version. Go 1.21+ should pull in new | |
# toolchains as indicated in go.mod. | |
go-version: '1.21' | |
- name: Determine Go version | |
id: get-go-version | |
# With go1.21+, we can use `go version` to print out the exact toolchain that will be used | |
run: | | |
echo "Building with Go $(go version | awk '{print $3}' | sed -e 's/^go//')" | |
echo "go-version=$(go version | awk '{print $3}' | sed -e 's/^go//')" >> $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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- 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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- 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" | |
repository: "http-echo" | |
- 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: [windows] | |
goarch: ["386", "amd64"] | |
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- 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: report | |
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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- 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: report | |
instructions: | | |
make build | |
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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- 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: report | |
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: ["arm64", "amd64"] | |
env: | |
repo: ${{ github.event.repository.name }} | |
version: ${{ needs.set-product-version.outputs.product-version }} | |
steps: | |
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- name: Docker Build (Action) | |
uses: hashicorp/actions-docker-build@v1 | |
with: | |
smoke_test: | | |
ls dist/linux/amd64/ | |
ls dist/linux/amd64/ | |
tree | |
TEST_VERSION="$(docker run "${IMAGE_NAME}" -version | awk '/http-echo/{print $2}' | sed s/v//)" | |
if [ "${TEST_VERSION}" != "${version}" ]; then | |
echo "Test FAILED" | |
echo "Test Version: ${TEST_VERSION}" | |
echo "Version: ${version}" | |
exit 1 | |
fi | |
echo "Test PASSED" | |
version: ${{ env.version }} | |
target: default | |
arch: ${{ matrix.arch }} | |
tags: | | |
docker.io/hashicorp/${{env.repo}}:${{env.version}} | |
dev_tags: | | |
docker.io/hashicorppreview/${{ env.repo }}:${{ env.version }}-dev | |
docker.io/hashicorppreview/${{ env.repo }}:${{ env.version }}-${{ github.sha }} | |