From 47da2f7bcd63ae1913ef542511bf01c67a8261bf Mon Sep 17 00:00:00 2001 From: Rohan Prabhu Date: Fri, 2 May 2025 19:52:21 +0530 Subject: [PATCH 1/2] chore: add buildflags to integration-test --- .github/workflows/int.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/int.yml b/.github/workflows/int.yml index 3a05f81..7a584fc 100644 --- a/.github/workflows/int.yml +++ b/.github/workflows/int.yml @@ -37,7 +37,7 @@ jobs: go mod vendor - run: sudo go test -v - - run: go build -ldflags="-s -w" -o ./agent + - run: go build -ldflags="-s -w -X main.commit=latest -X main.ReleaseTag=rc" -o ./agent - name: Configure aws credentials uses: aws-actions/configure-aws-credentials@ea7b857d8a33dc2fb4ef5a724500044281b49a5e with: From ae7e6eceabfa744aba521077b42e8cca1baace02 Mon Sep 17 00:00:00 2001 From: Rohan Prabhu Date: Fri, 2 May 2025 20:07:22 +0530 Subject: [PATCH 2/2] feat: update releasers --- .github/workflows/int.yml | 12 +++++++++++- .goreleaser.yml | 2 +- buildinfo.go | 7 ++++--- releasers/int.yml | 28 ++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 releasers/int.yml diff --git a/.github/workflows/int.yml b/.github/workflows/int.yml index 7a584fc..eed8aee 100644 --- a/.github/workflows/int.yml +++ b/.github/workflows/int.yml @@ -37,13 +37,23 @@ jobs: go mod vendor - run: sudo go test -v - - run: go build -ldflags="-s -w -X main.commit=latest -X main.ReleaseTag=rc" -o ./agent + + - uses: goreleaser/goreleaser-action@5df302e5e9e4c66310a6b6493a8865b12c555af2 + with: + distribution: goreleaser + version: latest + args: release --snapshot --clean --config releasers/int.yml + - name: Configure aws credentials uses: aws-actions/configure-aws-credentials@ea7b857d8a33dc2fb4ef5a724500044281b49a5e with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-west-2 + + - run: | + ls -lahR + - run: aws s3 cp ./agent s3://step-security-agent/refs/heads/int/agent --acl public-read - name: Integration test uses: docker://ghcr.io/step-security/integration-test/int:latest diff --git a/.goreleaser.yml b/.goreleaser.yml index 5d9aa26..9c6ead2 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -18,7 +18,7 @@ builds: flags: - -trimpath ldflags: - - -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date=123 -X main.ReleaseTag={{.Tag}} + - -s -w -X main.version={{.Version}} -X main.ReleaseCommit={{.FullCommit}} -X main.date=123 -X main.ReleaseTag={{.Tag}} -X ain.ReleaseBranch={{.Branch}} # Optionally override the matrix generation and specify only the final list of targets. diff --git a/buildinfo.go b/buildinfo.go index 2529809..b36b5b8 100644 --- a/buildinfo.go +++ b/buildinfo.go @@ -4,10 +4,11 @@ import "fmt" // filled through ldflags var ( - ReleaseTag = "" - commit = "" + ReleaseTag = "" + ReleaseBranch = "" + ReleaseCommit = "" ) func LogBuildInfo() { - WriteLog(fmt.Sprintf("[buildInfo] tag=%s commit=%s \n", ReleaseTag, commit)) + WriteLog(fmt.Sprintf("[buildInfo] tag=%s commit=%s branch=%s \n", ReleaseTag, ReleaseCommit, ReleaseBranch)) } diff --git a/releasers/int.yml b/releasers/int.yml new file mode 100644 index 0000000..7fe503b --- /dev/null +++ b/releasers/int.yml @@ -0,0 +1,28 @@ +# .goreleaser.yml +builds: + # You can have multiple builds defined as a yaml list + - + # GOOS list to build for. + # For more info refer to: https://golang.org/doc/install/source#environment + # Defaults are darwin and linux. + goos: + - linux + + # GOARCH to build for. + # For more info refer to: https://golang.org/doc/install/source#environment + # Defaults are 386, amd64 and arm64. + goarch: + - amd64 + + mod_timestamp: '123' + flags: + - -trimpath + ldflags: + - -s -w -X main.version={{.Version}} -X main.commit={{.FullCommit}} -X main.date=123 -X main.ReleaseTag=int -X main.ReleaseBranch=int -X main.ReleaseCommit={{.FullCommit}} + + + # Optionally override the matrix generation and specify only the final list of targets. + # Format is `{goos}_{goarch}` with optionally a suffix with `_{goarm}` or `_{gomips}`. + # This overrides `goos`, `goarch`, `goarm`, `gomips` and `ignores`. + targets: + - linux_amd64 \ No newline at end of file