Skip to content

Commit

Permalink
Automatic builds
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Nov 8, 2023
1 parent 8cfa3f6 commit 6443c92
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/prerelease.yml
@@ -0,0 +1,31 @@
name: Build and publish pre-release

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Build
run: ./build.ps1
shell: pwsh

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "prerelease"
prerelease: true
title: "Development Build"
files: |
binaries/*
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,29 @@
name: Build and publish release

on:
push:
tags: [ "*.*.*" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Build
run: ./build.ps1
shell: pwsh

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
binaries/*
2 changes: 2 additions & 0 deletions .gitignore
@@ -1 +1,3 @@
fastsync
binaries/*
.vscode
32 changes: 32 additions & 0 deletions build.ps1
@@ -0,0 +1,32 @@
function BuildVariants {
param (
$ldflags,
$compileflags,
$prefix,
$suffix,
$arch,
$os,
$path
)

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

Set-Location $PSScriptRoot

# Release
BuildVariants -ldflags "$LDFLAGS -s" -prefix fastsync -path . -arch @("386", "amd64", "arm64") -os @("linux")

0 comments on commit 6443c92

Please sign in to comment.