Skip to content

Commit

Permalink
Let's try adding CycloneDX SBOM to prereleases
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Sep 12, 2022
1 parent 4835a3e commit 7f5c89e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ jobs:
with:
go-version: 1.19

- name: Download cyclonedx-gomod
uses: CycloneDX/gh-gomod-generate-sbom@v1
with:
version: v1

- name: Build
run: ./build.ps1
shell: pwsh
Expand Down
40 changes: 18 additions & 22 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,24 @@ function BuildVariants {
param (
$ldflags,
$compileflags,
$suffix
$prefix,
$suffix,
$arch,
$os,
$path
)

$env:GOARCH = "386"
$env:GOOS = "windows"
go build -ldflags "$ldflags" -o binaries/adalanche-collector-windows-386-$VERSION$suffix.exe $compileflags ./collector

$env:GOARCH = "amd64"
$env:GOOS = "windows"
go build -ldflags "$ldflags" -o binaries/adalanche-windows-x64-$VERSION$suffix.exe $compileflags ./adalanche
$env:GOOS = "darwin"
go build -ldflags "$ldflags" -o binaries/adalanche-osx-x64-$VERSION$suffix $compileflags ./adalanche
$env:GOOS = "linux"
go build -ldflags "$ldflags" -o binaries/adalanche-linux-x64-$VERSION$suffix $compileflags ./adalanche

$env:GOARCH = "arm64"
$env:GOOS = "windows"
go build -ldflags "$ldflags" -o binaries/adalanche-windows-arm64-$VERSION$suffix.exe $compileflags ./adalanche
$env:GOOS = "linux"
go build -ldflags "$ldflags" -o binaries/adalanche-linux-arm64-$VERSION$suffix $compileflags ./adalanche
$env:GOOS = "darwin"
go build -ldflags "$ldflags" -o binaries/adalanche-osx-m1-$VERSION$suffix $compileflags ./adalanche

foreach ($currentarch in $arch) {
foreach ($currentos in $os) {
$env:GOARCH = $currentarch
$env:GOOS = $currentos
go build -ldflags "$ldflags" -o binaries/$prefix-$currentarch-$currentos-$VERSION$suffix.exe $compileflags $path
if (Get-Command "cyclonedx-gomod" -ErrorAction SilentlyContinue)
{
cyclonedx-gomod app -json -licenses -output binaries/$prefix-$currentarch-$currentos-$VERSION$suffix.bom.json -main $path .
}
}
}
}

Set-Location $PSScriptRoot
Expand All @@ -40,4 +35,5 @@ if ("$DIRTYFILES" -ne "") {
$LDFLAGS = "-X github.com/lkarlslund/adalanche/modules/version.Commit=$COMMIT -X github.com/lkarlslund/adalanche/modules/version.Version=$VERSION"

# Release
BuildVariants -ldflags "$LDFLAGS -s"
BuildVariants -ldflags "$LDFLAGS -s" -prefix adalanche-collector-windows -path ./collector -arch @("386") -os @("windows")
BuildVariants -ldflags "$LDFLAGS -s" -prefix adalanche-windows -path ./adalanche -arch @("amd64", "arm64") -os @("windows", "darwin", "linux")

0 comments on commit 7f5c89e

Please sign in to comment.