Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: skip LICENSE.txt copy for Ent releases #21055

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/scripts/copy-legal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

set -euo pipefail

repository_name=${1}
target_dirs="${@:2}"

if [ -z "$repository_name" ] || [ -z "$target_dirs" ]; then
echo "Error: repository_name and at least one value for target_dirs must be non-empty strings."
exit 1
fi

function copy_file {
for dir in $target_dirs; do
mkdir -p $dir
target_path="$dir/${2}"
echo "-> Copying $1 to $target_path"
cp "${1}" $target_path
done
}

if [[ $repository_name == *"-enterprise" ]]; then
echo "Copying legal (Ent)"
echo "Downloading EULA.txt and TermsOfEvaluation.txt"
curl -so /tmp/EULA.txt https://eula.hashicorp.com/EULA.txt
curl -so /tmp/TermsOfEvaluation.txt https://eula.hashicorp.com/TermsOfEvaluation.txt
copy_file /tmp/EULA.txt EULA.txt
copy_file /tmp/TermsOfEvaluation.txt TermsOfEvaluation.txt
else
echo "Copying legal (CE)"
copy_file LICENSE LICENSE.txt
fi
26 changes: 13 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
# Push events on the main branch
- main
- release/**
workflow_dispatch:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is only for test purpose right?


env:
PKG_NAME: consul
Expand Down Expand Up @@ -141,15 +142,10 @@ jobs:
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
cp LICENSE $TARGET_DIR/LICENSE.txt
go build -ldflags="$GOLDFLAGS" -o "$BIN_PATH" -trimpath -buildvcs=false

- name: Copy license file
env:
LICENSE_DIR: ".release/linux/package/usr/share/doc/${{ env.PKG_NAME }}"
run: |
mkdir -p "$LICENSE_DIR"
cp LICENSE "$LICENSE_DIR/LICENSE.txt"
# Note that for non-linux builds, .release/linux/package... is a no-op,
# but files will always included in the zip root directory (TARGET_DIR) on all platforms.
./.github/scripts/copy-legal.sh "${{ github.repository }}" "$TARGET_DIR" ".release/linux/package/usr/share/doc/${{ env.PKG_NAME }}"
${{ matrix.env }} go build -ldflags="$GOLDFLAGS" -tags="${{ matrix.gotags }}" -o "$BIN_PATH" -trimpath -buildvcs=false

- name: Package
if: ${{ matrix.goos == 'linux' }}
Expand Down Expand Up @@ -240,8 +236,10 @@ jobs:
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
cp LICENSE $TARGET_DIR/LICENSE.txt
go build -ldflags="$GOLDFLAGS" -o "$BIN_PATH" -trimpath -buildvcs=false
# Note that for non-linux builds, .release/linux/package... is a no-op,
# but files will always included in the zip root directory (TARGET_DIR) on all platforms.
./.github/scripts/copy-legal.sh "${{ github.repository }}" "$TARGET_DIR" ".release/linux/package/usr/share/doc/${{ env.PKG_NAME }}"
go build -ldflags="$GOLDFLAGS" -tags="${{ matrix.gotags }}" -o "$BIN_PATH" -trimpath -buildvcs=false

build-darwin:
needs:
Expand Down Expand Up @@ -291,8 +289,10 @@ jobs:
arch: ${{ matrix.goarch }}
reproducible: report
instructions: |-
cp LICENSE $TARGET_DIR/LICENSE.txt
go build -ldflags="$GOLDFLAGS" -tags netcgo -o "$BIN_PATH" -trimpath -buildvcs=false
# Note that for non-linux builds, .release/linux/package... is a no-op,
# but files will always included in the zip root directory (TARGET_DIR) on all platforms.
./.github/scripts/copy-legal.sh "${{ github.repository }}" "$TARGET_DIR" ".release/linux/package/usr/share/doc/${{ env.PKG_NAME }}"
go build -ldflags="$GOLDFLAGS" -tags="${{ matrix.gotags }}" -o "$BIN_PATH" -trimpath -buildvcs=false

build-docker:
name: Docker ${{ matrix.arch }} build
Expand Down