Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# If this file is renamed, the incrementing run attempt number will be reset.

name: CI

on:
push:
branches: [ "dev", "main" ]
pull_request:
branches: [ "dev", "main" ]

env:
CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
CI_PUBLISH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

jobs:
build-windows:
name: Build (Windows)
runs-on: windows-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Setup
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Build and Publish
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: |
./build/Build.Windows.ps1

build-linux:
name: Build (Linux)
runs-on: ubuntu-22.04

permissions:
contents: write

steps:
- uses: actions/checkout@v4
- name: Setup
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Configure Docker
run: |
docker run --privileged --rm linuxkit/binfmt:bebbae0c1100ebf7bf2ad4dfb9dfd719cf0ef132
sudo service docker restart
- name: Build and Publish
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
shell: pwsh
run: |
./build/Build.Linux.ps1
12 changes: 0 additions & 12 deletions Build.Common.ps1

This file was deleted.

11 changes: 0 additions & 11 deletions Setup.ps1

This file was deleted.

56 changes: 0 additions & 56 deletions appveyor.yml

This file was deleted.

1 change: 1 addition & 0 deletions baseversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2025.1
16 changes: 16 additions & 0 deletions build/Build.Common.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function Get-SemVer()
{
$branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
$revision = @{ $true = "{0:00000}" -f $([convert]::ToInt32($env:CI_BUILD_NUMBER_BASE, 10) + 2300); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER_BASE]
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"]
$commitHash = $(git rev-parse --short HEAD)
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]

$base = $(Get-Content ./baseversion).Trim()

if ($suffix) {
$base + "." + $revision + "-" + $suffix
} else {
$revision
}
}
37 changes: 20 additions & 17 deletions Build.Docker.ps1 → build/Build.Linux.ps1
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
Push-Location $PSScriptRoot
Push-Location $PSScriptRoot/../

. ./Build.Common.ps1
. ./build/Build.Common.ps1

$IsCIBuild = $null -ne $env:APPVEYOR_BUILD_NUMBER
$IsPublishedBuild = ($env:APPVEYOR_REPO_BRANCH -eq "main" -or $env:APPVEYOR_REPO_BRANCH -eq "dev") -and $null -eq $env:APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH
$version = Get-SemVer

$version = Get-SemVer(@{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL])
$framework = "net9.0"
$image = "datalust/seqcli"
$archs = @(
@{ rid = "x64"; platform = "linux/amd64" },
@{ rid = "arm64"; platform = "linux/arm64/v8" }
)

$endToEndVersion = "preview"

function Execute-Tests
{
& dotnet test ./test/SeqCli.Tests/SeqCli.Tests.csproj -c Release -f $framework /p:Configuration=Release /p:VersionPrefix=$version
if ($LASTEXITCODE -ne 0) { exit 1 }

cd ./test/SeqCli.EndToEnd/
docker pull "datalust/seq:$endToEndVersion"
docker tag "datalust/seq:$endToEndVersion" datalust/seq:latest
docker pull datalust/seq:latest
& dotnet run -f $framework -- --docker-server
if ($LASTEXITCODE -ne 0)
{
Expand All @@ -35,21 +30,27 @@ function Execute-Tests
function Build-DockerImage($arch)
{
$rid = "linux-$($arch.rid)"

& dotnet publish src/SeqCli/SeqCli.csproj -c Release -f $framework -r $rid --self-contained /p:VersionPrefix=$version /p:PublishSingleFile=true
if($LASTEXITCODE -ne 0) { exit 2 }

& docker buildx build --platform "$($arch.platform)" -f dockerfiles/seqcli/$rid.Dockerfile -t "$image-ci:$version-$($arch.rid)" .
if($LASTEXITCODE -ne 0) { exit 3 }
}

function Publish-DockerImage($arch)
function Login-ToDocker()
{
$ErrorActionPreference = "SilentlyContinue"

if ($IsCIBuild) {
Write-Output "$env:DOCKER_TOKEN" | docker login -u $env:DOCKER_USER --password-stdin
if ($LASTEXITCODE) { exit 3 }
}
Write-Output "$env:DOCKER_TOKEN" | docker login -u $env:DOCKER_USER --password-stdin
if ($LASTEXITCODE) { exit 3 }

$ErrorActionPreference = "Stop"
}

function Publish-DockerImage($arch)
{
$ErrorActionPreference = "SilentlyContinue"

& docker push "$image-ci:$version-$($arch.rid)"
if($LASTEXITCODE -ne 0) { exit 3 }
Expand All @@ -76,13 +77,15 @@ Execute-Tests

foreach ($arch in $archs) {
Build-DockerImage($arch)
}

if ($IsPublishedBuild) {
if ("$($env:DOCKER_TOKEN)" -ne "") {
Login-ToDocker

foreach ($arch in $archs) {
Publish-DockerImage($arch)
}
}

if ($IsPublishedBuild) {
Publish-DockerManifest($archs)
}

Expand Down
37 changes: 34 additions & 3 deletions Build.ps1 → build/Build.Windows.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Push-Location $PSScriptRoot
Push-Location $PSScriptRoot/../

. ./Build.Common.ps1
. ./build/Build.Common.ps1

$ErrorActionPreference = 'Stop'

$version = Get-SemVer(@{ $true = $env:APPVEYOR_BUILD_VERSION; $false = "99.99.99" }[$env:APPVEYOR_BUILD_VERSION -ne $NULL])
$version = Get-SemVer

$framework = 'net9.0'
$windowsTfmSuffix = '-windows'

Expand Down Expand Up @@ -78,6 +79,26 @@ function Publish-Docs($version)
if($LASTEXITCODE -ne 0) { throw "Build failed" }
}

function Upload-NugetPackages
{
# GitHub Actions will only supply this to branch builds and not PRs. We publish
# builds from any branch this action targets (i.e. main and dev).

Write-Output "build: Publishing NuGet packages"

foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
& dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
}
}

function Upload-GitHubRelease($version)
{
Write-Output "build: Creating release for version $version"

iex "gh release create v$version --title v$version --generate-notes $(get-item ./artifacts/*)"
}

function Remove-GlobalJson
{
if(Test-Path ./global.json) { rm ./global.json }
Expand All @@ -104,6 +125,16 @@ Publish-Archives($version)
Publish-DotNetTool($version)
Execute-Tests($version)
Publish-Docs($version)

if ("$($env:NUGET_API_KEY)" -ne "")
{
Upload-NugetPackages
}

if ($env:CI_PUBLISH -eq "True") {
Upload-GitHubRelease($version)
}

Remove-GlobalJson

Pop-Location
59 changes: 0 additions & 59 deletions docker-publish.ps1

This file was deleted.

18 changes: 0 additions & 18 deletions setup.sh

This file was deleted.

Loading