Skip to content

Commit

Permalink
ci: upload built binary assets to new releases
Browse files Browse the repository at this point in the history
  • Loading branch information
stigok committed Jan 11, 2024
1 parent 3d16771 commit dbe33ca
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
55 changes: 55 additions & 0 deletions .github/workflows/release-assets.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
ref: ${{ steps.setup.outputs.git_ref }}
-
name: Setup Go
uses: actions/[email protected]
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down

0 comments on commit dbe33ca

Please sign in to comment.