Skip to content

Commit c578678

Browse files
committed
Update GitHub actions and build script
1 parent cf250d1 commit c578678

File tree

3 files changed

+110
-102
lines changed

3 files changed

+110
-102
lines changed

.github/workflows/prerelease.yml

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
name: Build and publish pre-release
2-
3-
on:
4-
push:
5-
branches: [ main ]
6-
7-
jobs:
8-
build:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@v2
12-
with:
13-
fetch-depth: 0
14-
15-
- name: Set up Go
16-
uses: actions/setup-go@v2
17-
with:
18-
go-version: 1.21
19-
20-
- name: Build
21-
run: ./build.ps1
22-
shell: pwsh
23-
24-
- name: Archive production artifacts
25-
uses: actions/upload-artifact@v2
26-
with:
27-
name: Binaries
28-
path: binaries/*
29-
30-
- uses: "marvinpinto/action-automatic-releases@latest"
31-
with:
32-
repo_token: "${{ secrets.GITHUB_TOKEN }}"
33-
automatic_release_tag: "prerelease"
34-
prerelease: true
35-
title: "Development Build"
36-
files: |
1+
name: Build and publish pre-release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version: 1.22
19+
20+
- name: Build
21+
run: ./build.ps1
22+
shell: pwsh
23+
24+
- name: Archive production artifacts
25+
uses: actions/upload-artifact@v2
26+
with:
27+
name: Binaries
28+
path: binaries/*
29+
30+
- uses: "marvinpinto/action-automatic-releases@latest"
31+
with:
32+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
33+
automatic_release_tag: "prerelease"
34+
prerelease: true
35+
title: "Development Build"
36+
files: |
3737
binaries/*

.github/workflows/release.yml

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
name: Build and publish release
2-
3-
on:
4-
push:
5-
tags: [ "*.*.*" ]
6-
7-
jobs:
8-
build:
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@v2
12-
with:
13-
fetch-depth: 0
14-
15-
- name: Set up Go
16-
uses: actions/setup-go@v2
17-
with:
18-
go-version: 1.21
19-
20-
- name: Build
21-
run: ./build.ps1
22-
shell: pwsh
23-
24-
- name: Archive production artifacts
25-
uses: actions/upload-artifact@v2
26-
with:
27-
name: Binaries
28-
path: binaries/*
29-
30-
- uses: "marvinpinto/action-automatic-releases@latest"
31-
with:
32-
repo_token: "${{ secrets.GITHUB_TOKEN }}"
33-
prerelease: false
34-
files: |
1+
name: Build and publish release
2+
3+
on:
4+
push:
5+
tags: [ "*.*.*" ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version: 1.22
19+
20+
- name: Build
21+
run: ./build.ps1
22+
shell: pwsh
23+
24+
- name: Archive production artifacts
25+
uses: actions/upload-artifact@v2
26+
with:
27+
name: Binaries
28+
path: binaries/*
29+
30+
- uses: "marvinpinto/action-automatic-releases@latest"
31+
with:
32+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
33+
prerelease: false
34+
files: |
3535
binaries/*

build.ps1

+40-32
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
1-
function BuildVariants {
2-
param (
3-
$ldflags,
4-
$compileflags,
5-
$prefix,
6-
$suffix,
7-
$arch,
8-
$os,
9-
$path
10-
)
11-
12-
foreach ($currentarch in $arch) {
13-
foreach ($currentos in $os) {
14-
$env:GOARCH = $currentarch
15-
$env:GOOS = $currentos
16-
$outputfile = "binaries/$prefix-$currentos-$currentarch$suffix"
17-
if ($currentos -eq "windows") {
18-
$outputfile += ".exe"
19-
}
20-
go build -ldflags "$ldflags" -o $outputfile $compileflags $path
21-
if (Get-Command "cyclonedx-gomod" -ErrorAction SilentlyContinue)
22-
{
23-
cyclonedx-gomod app -json -licenses -output $outputfile.bom.json -main $path .
24-
}
25-
}
26-
}
27-
}
28-
29-
Set-Location $PSScriptRoot
30-
31-
# Release
32-
BuildVariants -ldflags "$LDFLAGS -s" -prefix ldapnomnom -path . -arch @("386", "amd64", "arm64") -os @("windows", "darwin", "linux")
1+
function BuildVariants {
2+
param (
3+
$ldflags,
4+
$compileflags,
5+
$prefix,
6+
$suffix,
7+
$arch,
8+
$os,
9+
$path
10+
)
11+
12+
foreach ($currentarch in $arch) {
13+
foreach ($currentos in $os) {
14+
$env:GOARCH = $currentarch
15+
$env:GOOS = $currentos
16+
17+
# More sensible naming for x64
18+
$namearch = $currentarch
19+
if ($namearch -eq "amd64") {
20+
$namearch = "x64"
21+
}
22+
23+
$outputfile = "binaries/$prefix-$currentos-$namearch$suffix"
24+
if ($currentos -eq "windows") {
25+
$outputfile += ".exe"
26+
}
27+
28+
go build -ldflags "$ldflags" -o $outputfile $compileflags $path
29+
if (Get-Command "cyclonedx-gomod" -ErrorAction SilentlyContinue)
30+
{
31+
cyclonedx-gomod app -json -licenses -output $outputfile.bom.json -main $path .
32+
}
33+
}
34+
}
35+
}
36+
37+
Set-Location $PSScriptRoot
38+
39+
# Release
40+
BuildVariants -ldflags "$LDFLAGS -s" -prefix ldapnomnom -path . -arch @("386", "amd64", "arm64") -os @("windows", "darwin", "linux")

0 commit comments

Comments
 (0)