Skip to content
Open
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
108 changes: 108 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: windows-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get base version from version.json
id: version
uses: notiz-dev/github-action-json-property@release
with:
path: version.json
prop_path: 'version'

- name: Set branch name (push)
if: startsWith(github.ref, 'refs/heads/')
shell: pwsh
run: |
$branch = "${{ github.ref }}" -replace 'refs/heads/', '' -replace '[\s_]', '-'
echo "BRANCH_NAME=$branch" >> $env:GITHUB_ENV

- name: Set branch name (PR)
if: startsWith(github.ref, 'refs/pull/')
shell: pwsh
run: |
$prNumber = "${{ github.ref }}" -replace 'refs/pull/', '' -replace '/merge', ''
echo "BRANCH_NAME=PR-$prNumber" >> $env:GITHUB_ENV

- name: Set package version (master)
if: github.ref == 'refs/heads/master'
shell: pwsh
run: |
$numericVersion = "${{ steps.version.outputs.prop }}.${{ github.run_number }}"
echo "PACKAGE_VERSION=$numericVersion" >> $env:GITHUB_ENV
echo "ASSEMBLY_VERSION=$numericVersion.0" >> $env:GITHUB_ENV

- name: Set package version (non-master)
if: github.ref != 'refs/heads/master'
shell: pwsh
run: |
$sha = "${{ github.sha }}".Substring(0, 8)
$numericVersion = "${{ steps.version.outputs.prop }}.${{ github.run_number }}"
echo "PACKAGE_VERSION=$numericVersion-$env:BRANCH_NAME-$sha" >> $env:GITHUB_ENV
echo "ASSEMBLY_VERSION=$numericVersion.0" >> $env:GITHUB_ENV

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.x'

- name: Restore dependencies
run: dotnet restore Seq.Client.WindowsLogins.sln

- name: Build
run: dotnet build Seq.Client.WindowsLogins.sln --configuration Release --no-restore /p:Version="$env:PACKAGE_VERSION" /p:AssemblyVersion="$env:ASSEMBLY_VERSION" /p:FileVersion="$env:ASSEMBLY_VERSION"

- name: Test
run: dotnet test Seq.Client.WindowsLogins.sln --configuration Release --no-build --verbosity normal

- name: Create release package
id: create_package
shell: pwsh
run: |
$outputDir = "Seq.Client.WindowsLogins/bin/Release/net462"
$zipName = "Seq.Client.WindowsLogins-$env:PACKAGE_VERSION.zip"
Compress-Archive -Path "$outputDir/*" -DestinationPath $zipName
echo "ZIP_NAME=$zipName" >> $env:GITHUB_ENV

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: Seq.Client.WindowsLogins-${{ env.PACKAGE_VERSION }}
path: Seq.Client.WindowsLogins/bin/Release/net462/

- name: Comment on PR with artifact link
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const version = process.env.PACKAGE_VERSION || 'unknown';
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `📦 **Build artifact ready:** \`Seq.Client.WindowsLogins-${version}\`\n\nDownload it from the [workflow run artifacts](${runUrl}#artifacts).`
});

- name: Create GitHub release
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.PACKAGE_VERSION }}
name: Release v${{ env.PACKAGE_VERSION }}
files: ${{ env.ZIP_NAME }}
generate_release_notes: true
3 changes: 3 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "1.1"
}