test all the way through to prepare #3437
Workflow file for this run
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: | |
push: | |
branches: | |
- main | |
- release/** | |
- fix-docker-vars | |
workflow_dispatch: | |
inputs: | |
build-ref: | |
description: 'The git ref to build from' | |
type: string | |
default: '' | |
required: false | |
make-prerelease: | |
description: "Run prerelease to generate files" | |
type: "boolean" | |
required: false | |
default: true | |
env: | |
PKG_NAME: "nomad" | |
GO_TAGS: "release" | |
jobs: | |
get-go-version: | |
runs-on: ubuntu-20.04 | |
outputs: | |
go-version: ${{ steps.get-go-version.outputs.go-version }} | |
steps: | |
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
with: | |
ref: ${{ github.event.inputs.build-ref }} | |
- 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" | |
get-product-version: | |
runs-on: ubuntu-20.04 | |
outputs: | |
product-version: ${{ steps.get-product-version.outputs.product-version }} | |
steps: | |
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
with: | |
ref: ${{ github.event.inputs.build-ref }} | |
- name: get product version | |
id: get-product-version | |
run: |- | |
make version | |
echo "product-version=$(make version)" >> "$GITHUB_OUTPUT" | |
generate-metadata-file: | |
needs: get-product-version | |
runs-on: ubuntu-20.04 | |
outputs: | |
filepath: ${{ steps.generate-metadata-file.outputs.filepath }} | |
steps: | |
- name: "Checkout directory" | |
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
with: | |
ref: ${{ github.event.inputs.build-ref }} | |
- name: Generate metadata file | |
id: generate-metadata-file | |
uses: hashicorp/[email protected] | |
with: | |
version: ${{ needs.get-product-version.outputs.product-version }} | |
product: ${{ env.PKG_NAME }} | |
repositoryOwner: "hashicorp" | |
sha: ${{ github.event.inputs.build-ref }} | |
- 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, get-product-version] | |
runs-on: [ custom, linux, xxl, 20.04 ] | |
strategy: | |
matrix: | |
goos: [windows] | |
goarch: ["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 | |
with: | |
ref: ${{ github.event.inputs.build-ref }} | |
- name: Setup go | |
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0 | |
with: | |
go-version: ${{ needs.get-go-version.outputs.go-version }} | |
- name: Build dependencies | |
run: make deps | |
- name: Setup node and yarn | |
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 | |
with: | |
node-version: "18" | |
cache-dependency-path: "ui/yarn.lock" | |
- name: Install Yarn | |
run: | | |
npm install -g yarn | |
- name: Build prerelease | |
run: make prerelease | |
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.make-prerelease == 'true' }} | |
- name: Build | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
GO_TAGS: ${{ env.GO_TAGS }} | |
CGO_ENABLED: 1 | |
run: | | |
make pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
mv pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | |
with: | |
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
path: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
build-linux: | |
needs: [get-go-version, get-product-version] | |
runs-on: [ custom, linux, xxl, 20.04 ] | |
strategy: | |
matrix: | |
goos: [linux] | |
goarch: ["arm", "arm64", "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 | |
with: | |
ref: ${{ github.event.inputs.build-ref }} | |
- name: Setup go | |
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0 | |
with: | |
go-version: ${{ needs.get-go-version.outputs.go-version }} | |
- name: Build dependencies | |
run: make deps | |
- name: Setup node and yarn | |
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 | |
with: | |
node-version: "18" | |
cache-dependency-path: "ui/yarn.lock" | |
- name: Install Yarn | |
run: | | |
npm install -g yarn | |
- name: Build prerelease | |
run: make prerelease | |
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.make-prerelease == 'true' }} | |
- name: Install Linux build utilties | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y software-properties-common | |
sudo apt-get update | |
sudo apt-get install -y \ | |
binutils-aarch64-linux-gnu \ | |
binutils-arm-linux-gnueabihf \ | |
gcc-aarch64-linux-gnu \ | |
gcc-arm-linux-gnueabihf \ | |
gcc-multilib-arm-linux-gnueabihf | |
- name: Set gcc | |
run: | | |
if [ "${{ matrix.goarch }}" == "arm" ]; then | |
echo "CC=arm-linux-gnueabihf-gcc" >> "$GITHUB_ENV" | |
elif [ "${{ matrix.goarch }}" == "arm64" ]; then | |
echo "CC=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV" | |
fi | |
- name: Build | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
GO_TAGS: ${{ env.GO_TAGS }} | |
CGO_ENABLED: 1 | |
run: | | |
make pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
mv pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | |
with: | |
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
path: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
- name: Package | |
uses: hashicorp/actions-packaging-linux@v1 | |
with: | |
name: ${{ env.PKG_NAME }} | |
description: "Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications." | |
arch: ${{ matrix.goarch }} | |
version: ${{ needs.get-product-version.outputs.product-version }} | |
maintainer: "HashiCorp" | |
homepage: "https://github.com/hashicorp/nomad" | |
license: "MPL-2.0" | |
binary: "pkg/${{ matrix.goos }}_${{ matrix.goarch }}/${{ env.PKG_NAME }}" | |
deb_depends: "openssl" | |
rpm_depends: "openssl" | |
config_dir: ".release/linux/package/" | |
preinstall: ".release/linux/preinst" | |
postinstall: ".release/linux/postinst" | |
postremove: ".release/linux/postrm" | |
- name: Set Package Names | |
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 | |
with: | |
name: ${{ env.RPM_PACKAGE }} | |
path: out/${{ env.RPM_PACKAGE }} | |
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | |
with: | |
name: ${{ env.DEB_PACKAGE }} | |
path: out/${{ env.DEB_PACKAGE }} | |
build-darwin: | |
needs: [get-go-version, get-product-version] | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
goos: [darwin] | |
goarch: ["arm64", "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 | |
with: | |
ref: ${{ github.event.inputs.build-ref }} | |
- name: Setup go | |
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0 | |
with: | |
go-version: ${{ needs.get-go-version.outputs.go-version }} | |
- name: Build dependencies | |
run: make deps | |
- name: Setup node and yarn | |
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 | |
with: | |
node-version: "18" | |
cache-dependency-path: "ui/yarn.lock" | |
- name: Install Yarn | |
run: | | |
npm install -g yarn | |
- name: Build prerelease | |
run: make prerelease | |
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.make-prerelease == 'true' }} | |
- name: Build | |
env: | |
GOOS: ${{ matrix.goos }} | |
GOARCH: ${{ matrix.goarch }} | |
GO_TAGS: "${{ env.GO_TAGS }} netcgo" | |
CGO_ENABLED: 1 | |
run: | | |
make pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
mv pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | |
with: | |
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip | |
path: ${{ 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: [ custom, linux, xxl, 20.04 ] | |
strategy: | |
matrix: | |
arch: ["arm64", "amd64"] | |
env: | |
version: ${{needs.get-product-version.outputs.product-version}} | |
revision: ${{github.sha}} | |
steps: | |
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 | |
- name: Set revision | |
if: "${{ github.event.inputs.build-ref != '' }}" | |
run: | | |
echo "revision=${{ github.event.inputs.build-ref }}" >> "$GITHUB_ENV" | |
- name: Docker Build (Action) | |
uses: hashicorp/actions-docker-build@v1 | |
with: | |
smoke_test: | | |
TEST_VERSION="$(docker run "${IMAGE_NAME}" version | awk '/Nomad v/{print $2}')" | |
if [ "${TEST_VERSION}" != "v${version}" ]; then | |
echo "Test FAILED" | |
exit 1 | |
fi | |
echo "Test PASSED" | |
version: ${{env.version}} | |
revision: ${{env.revision}} | |
target: release | |
arch: ${{matrix.arch}} | |
tags: | | |
docker.io/hashicorp/${{env.PKG_NAME}}:${{env.version}} | |
dev_tags: | | |
docker.io/hashicorppreview/${{ env.PKG_NAME }}:${{ env.version }}-dev | |
docker.io/hashicorppreview/${{ env.PKG_NAME }}:${{ env.version }}-${{env.revision}} | |
permissions: | |
contents: read |