diff --git a/.github/workflows/release-assets.yaml b/.github/workflows/release-assets.yaml new file mode 100644 index 00000000..89154c6c --- /dev/null +++ b/.github/workflows/release-assets.yaml @@ -0,0 +1,55 @@ +name: Build and upload assets (test) +on: + release: + types: [published] +#push: + +jobs: + build: + name: Build and push binaries + runs-on: ubuntu-latest + strategy: + matrix: + arch: + - amd64 + - arm64 + os: + - linux + steps: + - + name: Configure environment + id: setup + run: | + if [[ '${{ github.event_name }}' = 'published' ]] + then + echo 'git_ref=${{ github.ref }}' >> $GITHUB_OUTPUT + #else + # echo 'git_ref=${{ github.sha }}' >> $GITHUB_OUTPUT + fi + - + name: Checkout + uses: actions/checkout@v4.1.1 + with: + ref: ${{ steps.setup.outputs.git_ref }} + - + name: Setup Go + uses: actions/setup-go@v5.0.0 + with: + go-version-file: 'go.mod' + - + name: Build and upload + env: + GOOS: ${{ matrix.os }} + GOARCH: ${{ matrix.arch }} + VERSION: ${{ steps.setup.outputs.git_ref }} + run: | + LD_FLAGS="" + LD_FLAGS+=" -s" # no debug symbols + LD_FLAGS+=" -w" # no DWARF debug info + LD_FLAGS+=" -X 'main.buildDate=$(date --utc +%Y-%m-%dT%H:%M:%SZ)'" + LD_FLAGS+=" -X 'main.version=${VERSION}'" + + make LD_FLAGS="${LD_FLAGS}" build + tar -cvzf terraform-registry.tar.gz terraform-registry + gh release upload ${VERSION} terraform-registry.tar.gz%#%terraform-registry_${VERSION}_${GOOS}_${GOARCH}.tar.gz + rm terraform-registry terraform-registry.tar.gz diff --git a/Makefile b/Makefile index 81b7aae1..fd296ec0 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ all : reuse build test .PHONY: build build : - go build $(GO_FLAGS) -buildvcs=false -o $(BINARY_NAME) $(CMD_SOURCE) + go build -ldflags "$(LD_FLAGS)" $(GO_FLAGS) -o $(BINARY_NAME) $(CMD_SOURCE) .PHONY: build-docker build-docker :