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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Pull request validation: builds Release for every target framework. Publishes nothing.
# There is no unit test project; WpfSample is a manual sample and is built with the solution.
name: CI

on:
pull_request:
branches: [master, development]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.x'

- name: Restore workloads
run: dotnet workload restore DSoft.System.BluetoothLe/DSoft.System.BluetoothLe.csproj

- name: Restore
run: dotnet restore DSoft.System.BluetoothLe.slnx

- name: Build
run: dotnet build DSoft.System.BluetoothLe.slnx --configuration Release --no-restore
101 changes: 101 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Release: on every push to master, builds Release and pushes the DSoft.*.nupkg
# package (with its .snupkg symbols) to nuget.org as 4.0.yyMM.<run number>, then
# tags the commit and creates a GitHub release with the package attached.
# RELEASE_SUFFIX is empty for a stable version; set it to a suffix such as
# '-prerelease' to publish a prerelease.
# Signs in to nuget.org with Trusted Publishing (OIDC), so no API key is stored.
name: Release

on:
push:
branches: [master]
paths-ignore:
- '**.md'
- '.github/workflows/**'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: release
cancel-in-progress: false

env:
RELEASE_SUFFIX: ''

jobs:
release:
runs-on: windows-latest
environment: nuget
permissions:
contents: write # GitHub release and tag
id-token: write # Trusted Publishing
steps:
- uses: actions/checkout@v7

- uses: actions/setup-dotnet@v6
with:
dotnet-version: '10.x'

- name: Version
id: version
shell: bash
run: |
version="4.0.$(date -u +%y%m).${{ github.run_number }}"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "package=$version$RELEASE_SUFFIX" >> "$GITHUB_OUTPUT"
echo "Version: $version$RELEASE_SUFFIX"

- name: Restore workloads
run: dotnet workload restore DSoft.System.BluetoothLe/DSoft.System.BluetoothLe.csproj

- name: Restore
run: dotnet restore DSoft.System.BluetoothLe.slnx

# AssemblyVersion is deliberately not overridden. It is pinned in the csproj, because a strong-named
# assembly whose identity moves on every CI build forces consumers on net481 to carry a binding
# redirect. FileVersion still carries the build number, which is what a support engineer reads off
# a shipped file.
- name: Build
run: >
dotnet build DSoft.System.BluetoothLe.slnx --configuration Release --no-restore
/p:Version=${{ steps.version.outputs.package }}
/p:FileVersion=${{ steps.version.outputs.version }}

- name: Collect packages
shell: bash
run: |
mkdir -p artifacts
find DSoft.System.BluetoothLe -path '*/bin/Release/*' \( -name 'DSoft.*.nupkg' -o -name 'DSoft.*.snupkg' \) -exec cp {} artifacts/ \;
ls artifacts

- uses: actions/upload-artifact@v7
with:
name: drop
path: artifacts/*

- name: NuGet login
id: nuget
uses: NuGet/login@v1
with:
user: ${{ secrets.NUGET_USER }}

# The .snupkg next to each .nupkg is pushed with it.
- name: Push to nuget.org
shell: bash
run: |
for package in artifacts/*.nupkg; do
dotnet nuget push "$package" --api-key "${{ steps.nuget.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
done

- name: GitHub release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${{ steps.version.outputs.package }}" artifacts/*.nupkg \
--target "${{ github.sha }}" \
--title "${{ steps.version.outputs.package }}" \
--generate-notes \
${RELEASE_SUFFIX:+--prerelease}
4 changes: 2 additions & 2 deletions DSoft.System.BluetoothLe.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<Platform Name="x86" />
</Configurations>
<Folder Name="/.ci/">
<File Path="azure-pipelines-mergetest.yml" />
<File Path="azure-pipelines-release.yml" />
<File Path=".github/workflows/ci.yml" />
<File Path=".github/workflows/release.yml" />
<File Path="README.md" />
</Folder>
<Folder Name="/Samples/">
Expand Down
2 changes: 1 addition & 1 deletion DSoft.System.BluetoothLe/DSoft.System.BluetoothLe.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<ContinuousIntegrationBuild Condition="'$(TF_BUILD)' == 'true'">true</ContinuousIntegrationBuild>
<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true' Or '$(TF_BUILD)' == 'true'">true</ContinuousIntegrationBuild>
</PropertyGroup>

<!-- Packing on every Debug build costs time and produces artefacts nobody consumes. -->
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ dotnet build DSoft.System.BluetoothLe.slnx --no-restore
`net10.0-windows10.0.19041.0` and `net481` are only built when the host is Windows; on macOS and Linux the
remaining seven target frameworks build and the two Windows ones are skipped.

### Continuous integration

GitHub Actions (`.github/workflows/`):

- `ci.yml`: runs on pull requests to `master` and `development`. Builds Release for every target framework. Publishes nothing.
- `release.yml`: runs on every push to `master` (changes only to Markdown or workflow files are skipped; run it by hand to test a workflow change). Builds Release as `4.0.yyMM.<run number>` plus `RELEASE_SUFFIX` (empty for a stable version; set it to `-prerelease` in the workflow to publish a prerelease), uploads the package as the `drop` artifact and pushes it to nuget.org with Trusted Publishing (OIDC, `NUGET_USER` secret, `nuget` environment), then tags the commit `v<version>` and creates a GitHub release with the package attached. `AssemblyVersion` is not stamped by CI: it stays pinned in the project file (see "Strong naming").

### Strong naming

The assembly is strong-named with `DSoft.snk`, which is committed to this repository on purpose. A strong
Expand Down
54 changes: 0 additions & 54 deletions azure-pipelines-mergetest.yml

This file was deleted.

80 changes: 0 additions & 80 deletions azure-pipelines-release.yml

This file was deleted.

Loading