From d0fcb213094e8c48671a19dc3f65ce58f8c3aa72 Mon Sep 17 00:00:00 2001 From: Nara Kasbergen Kwon <855115+xiehan@users.noreply.github.com> Date: Tue, 23 Apr 2024 16:36:22 +0200 Subject: [PATCH] legal: Include license in release zip, Docker image and linux packages (#34977) --- .github/workflows/build-Dockerfile | 15 +++++++++++++++ .github/workflows/build-terraform-cli.yml | 22 ++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-Dockerfile b/.github/workflows/build-Dockerfile index c0ea5b89d3..46c130e5c6 100644 --- a/.github/workflows/build-Dockerfile +++ b/.github/workflows/build-Dockerfile @@ -29,8 +29,23 @@ LABEL version=$PRODUCT_VERSION # Historical Terraform-specific label preserved for backward compatibility. LABEL "com.hashicorp.terraform.version"="${PRODUCT_VERSION}" +# @see https://specs.opencontainers.org/image-spec/annotations/?v=v1.0.1#pre-defined-annotation-keys +LABEL org.opencontainers.image.title=${BIN_NAME} \ + org.opencontainers.image.description="Terraform enables you to safely and predictably create, change, and improve infrastructure" \ + org.opencontainers.image.authors="HashiCorp Terraform Team " \ + org.opencontainers.image.url="https://www.terraform.io/" \ + org.opencontainers.image.documentation="https://www.terraform.io/docs" \ + org.opencontainers.image.source="https://github.com/hashicorp/terraform" \ + org.opencontainers.image.version=${PRODUCT_VERSION} \ + org.opencontainers.image.revision=${PRODUCT_REVISION} \ + org.opencontainers.image.vendor="HashiCorp" \ + org.opencontainers.image.licenses="BUSL-1.1" + RUN apk add --no-cache git openssh +# Copy the license file as per Legal requirement +COPY LICENSE "/usr/share/doc/${BIN_NAME}/LICENSE.txt" + # The hashicorp/actions-docker-build GitHub Action extracts the appropriate # release package for our target architecture into the current working # directory before running "docker build", which we'll then copy into the diff --git a/.github/workflows/build-terraform-cli.yml b/.github/workflows/build-terraform-cli.yml index 030fd54b74..3fc3dc2703 100644 --- a/.github/workflows/build-terraform-cli.yml +++ b/.github/workflows/build-terraform-cli.yml @@ -42,8 +42,6 @@ jobs: - uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 with: go-version: ${{ inputs.go-version }} - - name: Determine artifact basename - run: echo "ARTIFACT_BASENAME=${{ inputs.package-name }}_${{ inputs.product-version }}_${{ inputs.goos }}_${{ inputs.goarch }}.zip" >> $GITHUB_ENV - name: Build Terraform env: GOOS: ${{ inputs.goos }} @@ -51,7 +49,7 @@ jobs: GO_LDFLAGS: ${{ inputs.ld-flags }} ACTIONSOS: ${{ inputs.runson }} CGO_ENABLED: ${{ inputs.cgo-enabled }} - uses: hashicorp/actions-go-build@v0.1.7 + uses: hashicorp/actions-go-build@e20c6be7bf010e40e930dab20e6da63176725ec1 # v0.1.9 with: product_name: ${{ inputs.package-name }} product_version: ${{ inputs.product-version }} @@ -60,15 +58,14 @@ jobs: arch: ${{ inputs.goarch }} reproducible: nope instructions: |- - mkdir dist out - set -x - go build -ldflags "${{ inputs.ld-flags }}" -o dist/ . - zip -r -j out/${{ env.ARTIFACT_BASENAME }} dist/ - - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 - with: - name: ${{ env.ARTIFACT_BASENAME }} - path: out/${{ env.ARTIFACT_BASENAME }} - if-no-files-found: error + go build -ldflags "${{ inputs.ld-flags }}" -o "$BIN_PATH" -trimpath -buildvcs=false + cp LICENSE "$TARGET_DIR/LICENSE.txt" + - name: Copy license file to config_dir + if: ${{ matrix.goos == 'linux' }} + env: + LICENSE_DIR: ".release/linux/package/usr/share/doc/${{ inputs.package-name }}" + run: | + mkdir -p "$LICENSE_DIR" && cp LICENSE "$LICENSE_DIR/LICENSE.txt" - if: ${{ inputs.goos == 'linux' }} uses: hashicorp/actions-packaging-linux@v1 with: @@ -82,6 +79,7 @@ jobs: binary: "dist/terraform" deb_depends: "git" rpm_depends: "git" + config_dir: ".release/linux/package/" - if: ${{ inputs.goos == 'linux' }} name: Determine package file names run: |