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
29 changes: 21 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,37 @@ jobs:
**/packages.lock.json
**/*.csproj

- name: Derive version + channel from tag
- name: Install Nerdbank.GitVersioning CLI
run: dotnet tool install --global nbgv --version 3.9.50

- name: Derive version + channel from NBGV
id: meta
shell: pwsh
run: |
$tag = "${{ github.ref_name }}"
$version = $tag.TrimStart('v')
# NBGV is the single source of truth — version.json + git height.
# On a tagged (public-release) build the SemVer2 string is clean
# (no commit-id suffix), e.g. 0.1.0-alpha.7 or 0.1.0 for a stable cut.
$json = nbgv get-version --format json | ConvertFrom-Json
if (-not $json.PublicRelease) {
Write-Error "NBGV did not treat ref '$($json.BuildingRef)' as a public release. The release tag must match publicReleaseRefSpec in version.json; create it with 'nbgv tag'."
exit 1
}
$version = $json.SemVer2
$prerelease = $json.PrereleaseVersionNoLeadingHyphen # 'alpha.7' or ''
# Emit lowercase 'true'/'false' explicitly — PowerShell's boolean
# string-interpolation produces 'True'/'False' (capitalised), which
# softprops/action-gh-release@v2 silently treats as falsy.
if ($version.Contains('-')) {
if ($prerelease) {
$isPrerelease = 'true'
$channel = ($version -split '-', 2)[1] -replace '\..*$', ''
if ([string]::IsNullOrWhiteSpace($channel)) { $channel = 'beta' }
$channel = ($prerelease -split '\.')[0] # 'alpha'
} else {
$isPrerelease = 'false'
$channel = 'stable'
}
"version=$version" >> $env:GITHUB_OUTPUT
"isPrerelease=$isPrerelease" >> $env:GITHUB_OUTPUT
"channel=$channel" >> $env:GITHUB_OUTPUT
Write-Host "Tag : $tag"
Write-Host "Tag : ${{ github.ref_name }}"
Write-Host "Version : $version"
Write-Host "Pre-release : $isPrerelease"
Write-Host "Channel : $channel"
Expand All @@ -70,7 +80,10 @@ jobs:
run: dotnet test tests/Snipdeck.Core.Tests/Snipdeck.Core.Tests.csproj --configuration Release --no-restore

- name: Publish Snipdeck.App (win-x64)
run: dotnet publish src/Snipdeck.App/Snipdeck.App.csproj --configuration Release --runtime win-x64 --self-contained true --output publish -p:Version=${{ steps.meta.outputs.version }}
# No -p:Version here — Nerdbank.GitVersioning stamps the assemblies at
# build time from version.json + git height (the same number the meta
# step reads), so an explicit Version would be redundant and ignored.
run: dotnet publish src/Snipdeck.App/Snipdeck.App.csproj --configuration Release --runtime win-x64 --self-contained true --output publish

- name: Install Velopack CLI
run: dotnet tool install -g vpk
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- **Git-derived version numbers (Nerdbank.GitVersioning).** Every build now
stamps a real version (`0.1.0-alpha.<git-height>+<commit>`) into all
assemblies from a single `version.json`, so the About page shows a meaningful
version for dev and CI builds instead of the `1.0.0` compile-time fallback.
Releases derive their version from NBGV rather than the tag string — see
CONTRIBUTING.md for the `nbgv tag` release flow.
- **Trash.** A "Trash" entry in the pane footer lists soft-deleted snips from
across every CLI. Each can be **Restored** (returned to its CLI) or **Deleted
permanently** (after confirmation). Previously, deleting a snip moved it to
Expand Down
32 changes: 25 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,33 @@ project boundary.

## Releases

Releases are driven by git tags:
The version number is owned by [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning)
(NBGV), not by the tag you type. `version.json` at the repo root holds the base
(`0.1.0-alpha.{height}`); NBGV derives the full version from it plus the git
commit height, stamps every assembly, and the workflow reads it back at release
time. So you don't hand-pick the `-alpha.N` counter — it tracks git height.

- `v1.2.3` — stable release.
- `v1.2.3-rc.1`, `v1.2.3-beta.4`, etc. — pre-release. The hyphen in the tag
marks the GitHub release as a pre-release and feeds Velopack's channel name.
Releases are still driven by git tags, but **create the tag with NBGV so its
name matches the computed version** (install once with
`dotnet tool install --global nbgv`):

Pushing a matching tag triggers `.github/workflows/release.yml`, which builds
`Snipdeck.App`, packs it with Velopack, and attaches the artefacts to a new
GitHub Release. Don't push tags from feature branches — release from `master`.
```
git checkout master && git pull
nbgv tag # mints e.g. v0.1.0-alpha.7 for the current commit
git push origin v0.1.0-alpha.7
```

Pushing a matching tag triggers `.github/workflows/release.yml`, which derives
the version from `nbgv get-version` (asserting it's a public release per
`publicReleaseRefSpec`), builds `Snipdeck.App`, packs it with Velopack, and
attaches the artefacts to a new GitHub Release. The hyphen in the version
(`-alpha`, `-beta`, …) marks the GitHub release as a pre-release and feeds
Velopack's channel name. Don't tag from feature branches — release from
`master`.

To cut a **stable** release (or move to a new line), edit `version.json` first
— e.g. `0.1.0-alpha.{height}` → `0.1.0` for the first stable, or bump to
`0.2.0-alpha.{height}` — commit that on `master`, then `nbgv tag` and push.

## Asking for direction

Expand Down
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<!-- Nerdbank.GitVersioning stamps every assembly with a git-derived version
(base + height + commit hash) from the repo-root version.json. Build-time
only, so PrivateAssets="all" keeps it out of downstream references. -->
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" PrivateAssets="all" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>

<!-- Build-time, all projects -->
<ItemGroup>
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.9.50" />
</ItemGroup>

<!-- Core -->
<ItemGroup>
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.2" />
Expand Down
8 changes: 8 additions & 0 deletions version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.1.0-alpha.{height}",
"versionHeightOffset": 1,
"publicReleaseRefSpec": [
"^refs/tags/v\\d+\\.\\d+\\.\\d+"
]
}
Loading