This repository was archived by the owner on Jun 27, 2025. It is now read-only.
Release v0.4.0 #233
This file contains hidden or 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: | |
| workflow_dispatch: | |
| workflow_call: | |
| env: | |
| PKG_NAME: "levant" | |
| jobs: | |
| get-go-version: | |
| name: "Determine Go toolchain version" | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| go-version: ${{ steps.get-go-version.outputs.go-version }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Determine Go version | |
| id: get-go-version | |
| run: | | |
| echo "Building with Go $(cat .go-version)" | |
| echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT" | |
| get-product-version: | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| product-version: ${{ steps.get-product-version.outputs.product-version }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - 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-22.04 | |
| outputs: | |
| filepath: ${{ steps.generate-metadata-file.outputs.filepath }} | |
| steps: | |
| - name: "Checkout directory" | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Generate metadata file | |
| id: generate-metadata-file | |
| uses: hashicorp/actions-generate-metadata@fdbc8803a0e53bcbb912ddeee3808329033d6357 # v1.1.1 | |
| with: | |
| version: ${{ needs.get-product-version.outputs.product-version }} | |
| product: ${{ env.PKG_NAME }} | |
| repository: ${{ env.PKG_NAME }} | |
| repositoryOwner: "hashicorp" | |
| - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | |
| if: ${{ !env.ACT }} | |
| with: | |
| name: metadata.json | |
| path: ${{ steps.generate-metadata-file.outputs.filepath }} | |
| generate-ldflags: | |
| needs: get-product-version | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| ldflags: ${{ steps.generate-ldflags.outputs.ldflags }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Generate ld flags | |
| id: generate-ldflags | |
| run: | | |
| echo "ldflags=-X 'github.com/hashicorp/levant/version.GitDescribe=v${{ needs.get-product-version.outputs.product-version }}'" >> "$GITHUB_OUTPUT" | |
| build: | |
| needs: | |
| - get-go-version | |
| - get-product-version | |
| - generate-ldflags | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| goos: ["linux", "darwin", "windows", "freebsd"] | |
| goarch: [ "amd64", "arm64"] | |
| fail-fast: true | |
| name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Setup go | |
| uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | |
| with: | |
| go-version-file: ".go-version" | |
| - name: Build Levant | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| GO_LDFLAGS: ${{ needs.generate-ldflags.outputs.ldflags }} | |
| CGO_ENABLED: "0" | |
| BIN_PATH: dist/levant | |
| uses: hashicorp/actions-go-build@37358f6098ef21b09542d84a9814ebb843aa4e3e # v1.0.0 | |
| with: | |
| product_name: ${{ env.PKG_NAME }} | |
| product_version: ${{ needs.get-product-version.outputs.product-version }} | |
| go_version: ${{ needs.get-go-version.outputs.go-version }} | |
| os: ${{ matrix.goos }} | |
| arch: ${{ matrix.goarch }} | |
| reproducible: nope | |
| instructions: |- | |
| make crt | |
| - if: ${{ matrix.goos == 'linux' }} | |
| uses: hashicorp/actions-packaging-linux@8d55a640bb30b5508f16757ea908b274564792d4 # v1.7.0 | |
| with: | |
| name: "levant" | |
| description: "Levant is a templating and deployment tool for HashiCorp Nomad" | |
| arch: ${{ matrix.goarch }} | |
| version: ${{ needs.get-product-version.outputs.product-version }} | |
| maintainer: "HashiCorp" | |
| homepage: "https://github.com/hashicorp/levant" | |
| license: "MPL-2.0" | |
| binary: "dist/levant" | |
| deb_depends: "openssl" | |
| rpm_depends: "openssl" | |
| - if: ${{ matrix.goos == 'linux' }} | |
| name: Determine package file names | |
| run: | | |
| echo "RPM_PACKAGE=$(basename out/*.rpm)" >> "$GITHUB_ENV" | |
| echo "DEB_PACKAGE=$(basename out/*.deb)" >> "$GITHUB_ENV" | |
| - if: ${{ matrix.goos == 'linux' }} | |
| uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | |
| with: | |
| name: ${{ env.RPM_PACKAGE }} | |
| path: out/${{ env.RPM_PACKAGE }} | |
| if-no-files-found: error | |
| - if: ${{ matrix.goos == 'linux' }} | |
| uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | |
| with: | |
| name: ${{ env.DEB_PACKAGE }} | |
| path: out/${{ env.DEB_PACKAGE }} | |
| if-no-files-found: error | |
| build-docker-default: | |
| needs: | |
| - get-product-version | |
| - build | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| arch: ["arm64", "amd64"] | |
| fail-fast: true | |
| env: | |
| version: ${{ needs.get-product-version.outputs.product-version }} | |
| name: Docker ${{ matrix.arch }} default release build | |
| steps: | |
| - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 | |
| - name: Docker Build (Action) | |
| uses: hashicorp/actions-docker-build@11d43ef520c65f58683d048ce9b47d6617893c9a # v2.0.0 | |
| with: | |
| smoke_test: | | |
| TEST_VERSION="$(docker run "${IMAGE_NAME}" version | awk '/Levant/{print $2}')" | |
| if [ "${TEST_VERSION}" != "v${version}" ]; then | |
| echo "Test FAILED" | |
| exit 1 | |
| fi | |
| echo "Test PASSED" | |
| version: ${{ needs.get-product-version.outputs.product-version }} | |
| 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 }}-${{ github.sha }} | |
| permissions: | |
| contents: read |