Merge pull request #13 from poli0981/claude/phase6c-cicd
Phase 6c: CI/CD, Velopack release pipeline, version fix, build/update docs
This commit is contained in:
10 files changed
+387
-1
No files matched your search
@@ -0,0 +1,17 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: nuget
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 5
|
||||
commit-message:
|
||||
prefix: "deps"
|
||||
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 5
|
||||
commit-message:
|
||||
prefix: "ci"
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Announce Release
|
||||
|
||||
# Posts a release announcement to Discord (reuses the shared workflow in poli0981/.github).
|
||||
# Requires repo/org secret DISCORD_RELEASES_WEBHOOK (or DISCORD_REPO_WEBHOOK); optional
|
||||
# DISCORD_PING_ROLE_ID. No-op effect if those secrets are unset (the job will error — set them
|
||||
# or disable this workflow).
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: Release tag to announce (e.g. v0.3.0)
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
announce:
|
||||
uses: poli0981/.github/.github/workflows/announce-release.yml@main
|
||||
with:
|
||||
tag_override: ${{ github.event.inputs.tag || '' }}
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,34 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# WPF (net10.0-windows) only builds on Windows.
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '10.0.x'
|
||||
|
||||
- name: Restore
|
||||
run: dotnet restore CommandForge.slnx
|
||||
|
||||
- name: Verify formatting
|
||||
run: dotnet format CommandForge.slnx --verify-no-changes --no-restore
|
||||
|
||||
- name: Build (Release, warnings = errors)
|
||||
run: dotnet build CommandForge.slnx -c Release --no-restore
|
||||
|
||||
- name: Test
|
||||
run: dotnet test CommandForge.slnx -c Release --no-build
|
||||
@@ -0,0 +1,45 @@
|
||||
name: CodeQL
|
||||
|
||||
# Project-specific CodeQL (not the shared reusable codeql-csharp.yml): this is a WPF
|
||||
# (net10.0-windows) app that only builds on Windows and uses a .slnx solution, whereas the
|
||||
# reusable workflow runs on ubuntu and looks for a .sln.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: '37 14 * * 1' # Mondays 14:37 UTC
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze (csharp)
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '10.0.x'
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
with:
|
||||
languages: csharp
|
||||
queries: security-extended
|
||||
|
||||
- name: Build
|
||||
run: dotnet build CommandForge.slnx -c Release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3
|
||||
with:
|
||||
category: "/language:csharp"
|
||||
@@ -0,0 +1,14 @@
|
||||
name: Notify CI Failure
|
||||
|
||||
# Posts a Discord alert when the Build workflow fails on main (reuses the shared workflow in
|
||||
# poli0981/.github). Requires repo/org secret DISCORD_CI_WEBHOOK.
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Build"]
|
||||
types: [completed]
|
||||
|
||||
jobs:
|
||||
notify:
|
||||
uses: poli0981/.github/.github/workflows/notify-ci-failure.yml@main
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,93 @@
|
||||
name: Release
|
||||
|
||||
# Triggered by pushing a SemVer tag (vX.Y.Z). Builds a self-contained, Velopack-packaged
|
||||
# release and publishes it to GitHub Releases with SHA-256 checksums and (optionally) a
|
||||
# VirusTotal scan. No code signing yet (see SECURITY.md).
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version without the leading v (e.g. 0.3.0)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
REPO_URL: https://github.com/poli0981/CommandForge
|
||||
VT_API_KEY: ${{ secrets.VT_API_KEY }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '10.0.x'
|
||||
|
||||
- name: Resolve version and tag
|
||||
id: ver
|
||||
shell: pwsh
|
||||
run: |
|
||||
if ('${{ github.event_name }}' -eq 'workflow_dispatch') {
|
||||
$version = '${{ github.event.inputs.version }}'
|
||||
$tag = "v$version"
|
||||
} else {
|
||||
$tag = '${{ github.ref_name }}'
|
||||
$version = $tag -replace '^v', ''
|
||||
}
|
||||
"version=$version" >> $env:GITHUB_OUTPUT
|
||||
"tag=$tag" >> $env:GITHUB_OUTPUT
|
||||
Write-Host "Releasing $version (tag $tag)"
|
||||
|
||||
- name: Install Velopack CLI (vpk)
|
||||
shell: pwsh
|
||||
run: |
|
||||
dotnet tool install -g vpk
|
||||
"$env:USERPROFILE\.dotnet\tools" >> $env:GITHUB_PATH
|
||||
|
||||
- name: Download previous release (delta base)
|
||||
continue-on-error: true # first release has nothing to download
|
||||
run: vpk download github --repoUrl $env:REPO_URL --token ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
|
||||
- name: Publish + pack (Velopack)
|
||||
run: ./scripts/pack.ps1 -Version ${{ steps.ver.outputs.version }}
|
||||
shell: pwsh
|
||||
|
||||
- name: Publish GitHub Release (Velopack)
|
||||
run: >
|
||||
vpk upload github
|
||||
--repoUrl $env:REPO_URL
|
||||
--token ${{ secrets.GITHUB_TOKEN }}
|
||||
--publish
|
||||
--releaseName "CommandForge ${{ steps.ver.outputs.version }}"
|
||||
--tag ${{ steps.ver.outputs.tag }}
|
||||
shell: pwsh
|
||||
|
||||
- name: SHA-256 checksums
|
||||
shell: pwsh
|
||||
run: |
|
||||
$rel = Join-Path (Get-Location) 'Releases'
|
||||
Get-ChildItem $rel -File -Exclude 'checksums.txt' |
|
||||
Get-FileHash -Algorithm SHA256 |
|
||||
ForEach-Object { '{0} {1}' -f $_.Hash.ToLower(), (Split-Path $_.Path -Leaf) } |
|
||||
Out-File (Join-Path $rel 'checksums.txt') -Encoding ascii
|
||||
gh release upload ${{ steps.ver.outputs.tag }} (Join-Path $rel 'checksums.txt') --clobber
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: VirusTotal scan (optional)
|
||||
if: env.VT_API_KEY != ''
|
||||
uses: crazy-max/ghaction-virustotal@v4
|
||||
with:
|
||||
vt_api_key: ${{ env.VT_API_KEY }}
|
||||
update_release_body: true
|
||||
files: |
|
||||
Releases/*-Setup.exe
|
||||
Releases/*-full.nupkg
|
||||
@@ -0,0 +1,59 @@
|
||||
# Building CommandForge
|
||||
|
||||
## Requirements
|
||||
|
||||
- Windows 10 (22H2) or Windows 11
|
||||
- **.NET 10 SDK** (`dotnet --version` → `10.0.x`)
|
||||
- For packaging: the **Velopack CLI** — `dotnet tool install -g vpk`
|
||||
- Admin rights are only needed to **test** elevated commands, not to build.
|
||||
|
||||
The solution file is **`CommandForge.slnx`** (the XML solution format).
|
||||
|
||||
## Build, run, test
|
||||
|
||||
```bash
|
||||
dotnet restore CommandForge.slnx
|
||||
dotnet build CommandForge.slnx -c Release # must be 0 warnings (warnings are errors)
|
||||
dotnet run --project src/CommandForge.Wpf
|
||||
dotnet test CommandForge.slnx
|
||||
```
|
||||
|
||||
## Code style
|
||||
|
||||
```bash
|
||||
dotnet format CommandForge.slnx # apply formatting
|
||||
dotnet format CommandForge.slnx --verify-no-changes # CI gate
|
||||
```
|
||||
|
||||
The build enforces analyzers as errors (`TreatWarningsAsErrors`, `EnforceCodeStyleInBuild`),
|
||||
including unused-using/unused-member rules.
|
||||
|
||||
## Publish (self-contained) + package
|
||||
|
||||
```bash
|
||||
# One-step helper (publish + vpk pack):
|
||||
pwsh ./scripts/pack.ps1 -Version 0.3.0
|
||||
```
|
||||
|
||||
`pack.ps1` runs a self-contained `win-x64` publish (stamping the assembly version so the in-app
|
||||
version matches the release) and then `vpk pack`. It writes these artifacts to `Releases/`:
|
||||
|
||||
- `CommandForge-win-Setup.exe` — the installer
|
||||
- `CommandForge-<version>-full.nupkg` — full package
|
||||
- `CommandForge-<version>-delta.nupkg` — delta package (only when a previous full is present)
|
||||
- `releases.win.json` / `RELEASES` — the update manifest read by the app
|
||||
|
||||
The `CommandForge.Elevator` helper is published into the same folder automatically (see the
|
||||
`PublishElevatorOnPublish` target in `src/CommandForge.Wpf/CommandForge.Wpf.csproj`).
|
||||
|
||||
> No code signing yet — see [SECURITY.md](.github/SECURITY.md). Don't add a signing step until
|
||||
> Azure Trusted Signing (or SignPath Foundation for OSS) is set up.
|
||||
|
||||
## CI
|
||||
|
||||
- **`build.yml`** — restore + `dotnet format --verify-no-changes` + Release build + tests on every
|
||||
PR/push to `main` (Windows).
|
||||
- **`codeql.yml`** — CodeQL C# analysis (Windows, builds `CommandForge.slnx`).
|
||||
- **`release.yml`** — see [RELEASING.md](RELEASING.md).
|
||||
|
||||
See [UPDATES.md](UPDATES.md) for how auto-update works.
|
||||
@@ -0,0 +1,50 @@
|
||||
# Releasing CommandForge
|
||||
|
||||
Releases are automated by [`release.yml`](.github/workflows/release.yml), triggered by pushing a
|
||||
SemVer tag.
|
||||
|
||||
## Steps
|
||||
|
||||
1. Update `docs/Changelog.md` (internal) and make sure `main` is green.
|
||||
2. Choose a SemVer version `X.Y.Z`.
|
||||
3. Tag and push:
|
||||
```bash
|
||||
git tag v0.3.0
|
||||
git push origin v0.3.0
|
||||
```
|
||||
4. The **Release** workflow runs on `windows-latest` and:
|
||||
- resolves the version from the tag (`vX.Y.Z` → `X.Y.Z`),
|
||||
- installs `vpk`,
|
||||
- **downloads the previous release** (`vpk download github`) so a delta can be computed
|
||||
(skipped/ignored on the very first release),
|
||||
- publishes self-contained and packages with Velopack (`scripts/pack.ps1`, which stamps the
|
||||
assembly version),
|
||||
- **publishes the GitHub Release** with all `Releases/` assets (`vpk upload github --publish`),
|
||||
- generates **`checksums.txt`** (SHA-256) and attaches it,
|
||||
- if `VT_API_KEY` is set, submits `Setup.exe` + `*-full.nupkg` to **VirusTotal** and appends the
|
||||
scan links to the release notes.
|
||||
5. Edit the GitHub Release notes if needed (changelog highlights). The SHA-256 + VirusTotal info is
|
||||
already attached.
|
||||
|
||||
You can also run the workflow manually (**Actions → Release → Run workflow**) with a `version`
|
||||
input; it tags `vX.Y.Z` via the upload step.
|
||||
|
||||
## Required repository secrets
|
||||
|
||||
| Secret | Used for | Required |
|
||||
|---|---|---|
|
||||
| `GITHUB_TOKEN` | Create the release & upload assets | automatic |
|
||||
| `VT_API_KEY` | VirusTotal scan + links | optional (step skipped if unset) |
|
||||
| `DISCORD_RELEASES_WEBHOOK` (or `DISCORD_REPO_WEBHOOK`) | Release announcement to Discord | optional |
|
||||
| `DISCORD_PING_ROLE_ID` | Role ping on stable releases | optional |
|
||||
| `DISCORD_CI_WEBHOOK` | Build-failure alerts to Discord | optional |
|
||||
|
||||
> `poli0981` is a user account (not an org), so secrets are set **per repository**
|
||||
> (Settings → Secrets and variables → Actions).
|
||||
|
||||
## Code signing
|
||||
|
||||
Not done yet. Releases ship unsigned; users may see a SmartScreen "unknown publisher" warning.
|
||||
Mitigations: SHA-256 + VirusTotal (above), no obfuscation, public source. When Azure Trusted
|
||||
Signing (or SignPath Foundation) is configured, add a signing step after `dotnet publish` and
|
||||
before `vpk pack`, and update [SECURITY.md](.github/SECURITY.md).
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
# How updates work (Velopack)
|
||||
|
||||
CommandForge installs and updates itself with [Velopack](https://velopack.io/). Updates are
|
||||
**per-user** and need **no UAC**.
|
||||
|
||||
## For users
|
||||
|
||||
1. Download `CommandForge-win-Setup.exe` from the
|
||||
[latest release](https://github.com/poli0981/CommandForge/releases) and run it. It installs
|
||||
per-user under `%LocalAppData%\CommandForge`.
|
||||
2. After that, the app checks GitHub Releases for newer versions (on startup if enabled, or via
|
||||
**Help → Check for updates** / `F5`) and updates itself. When a newer version exists it downloads
|
||||
the update (a small **delta** when possible) and applies it on restart.
|
||||
|
||||
The only network connection involved is to GitHub (see [PRIVACY.md](PRIVACY.md)). Update errors are
|
||||
mapped to clear messages: offline, not found (404), rate limited (403/429), and server error (5xx).
|
||||
|
||||
## How it works under the hood
|
||||
|
||||
- The app calls `VelopackApp.Build().Run()` at startup to handle install/update/uninstall hooks.
|
||||
- It checks for updates via `UpdateManager(new GithubSource("https://github.com/poli0981/CommandForge", null, prerelease: false))`.
|
||||
- Auto-update only works for an **installed** build (not a dev/portable run); the app detects this
|
||||
and hides update prompts otherwise.
|
||||
|
||||
## Release artifacts and the delta mechanism
|
||||
|
||||
Each release (see [RELEASING.md](RELEASING.md)) uploads the contents of `Releases/`:
|
||||
|
||||
| Asset | Purpose |
|
||||
|---|---|
|
||||
| `CommandForge-win-Setup.exe` | First-time installer |
|
||||
| `CommandForge-<version>-full.nupkg` | Full package (fallback / first install of a version) |
|
||||
| `CommandForge-<version>-delta.nupkg` | Delta from the previous version (small download) |
|
||||
| `releases.win.json` / `RELEASES` | Update manifest the client reads |
|
||||
| `checksums.txt` | SHA-256 of the assets (manual verification) |
|
||||
|
||||
**First release (e.g. `v0.3.0`):** there is no previous version, so only a **full** package +
|
||||
`Setup.exe` + manifest are produced and uploaded.
|
||||
|
||||
**Subsequent releases (e.g. `v0.3.1`):** Velopack needs the **previous** `-full.nupkg` present
|
||||
while packing to compute the delta. The release workflow does this automatically by running
|
||||
`vpk download github` before `vpk pack`, so each release after the first produces **both** a
|
||||
`-full.nupkg` and a `-delta.nupkg`. Clients already on `0.3.0` download only the small
|
||||
`-delta.nupkg`; the full package remains the fallback.
|
||||
|
||||
> If you ever build a release **locally**, run `vpk download github --repoUrl <repo>` first so the
|
||||
> prior full package is available for the delta — otherwise only a full package is produced.
|
||||
+5
-1
@@ -32,9 +32,13 @@ $publishDir = Join-Path $repoRoot "publish/$Runtime"
|
||||
$wpfProject = Join-Path $repoRoot 'src/CommandForge.Wpf'
|
||||
|
||||
Write-Host "Publishing CommandForge $Version ($Runtime, $Configuration)..." -ForegroundColor Cyan
|
||||
# Stamp the assembly version so the in-app "App version" (Settings -> About, Report Bug) matches
|
||||
# the released package version; otherwise it stays at the 1.0.0 default regardless of the tag.
|
||||
dotnet publish $wpfProject `
|
||||
-c $Configuration -r $Runtime --self-contained true `
|
||||
-p:PublishSingleFile=false -o $publishDir
|
||||
-p:PublishSingleFile=false `
|
||||
-p:Version=$Version -p:InformationalVersion=$Version `
|
||||
-o $publishDir
|
||||
|
||||
# vpk is the Velopack CLI: dotnet tool install -g vpk
|
||||
if (-not (Get-Command vpk -ErrorAction SilentlyContinue)) {
|
||||
|
||||
Reference in new issue
Block a user