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
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
"version": "5.6.0",
"version": "5.6.1",
"commands": [
"reportgenerator"
],
Expand Down
22 changes: 18 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
# Opens pull requests when dependencies have updates, including security fixes.
# Minor and patch updates are grouped into one PR per ecosystem to keep the noise down.
# One pull request per ecosystem each week, grouping every update in it. Security updates (enabled in
# the repository settings) still arrive as soon as an advisory is published, outside this schedule.
version: 2
updates:
- package-ecosystem: nuget
directory: /
schedule:
interval: weekly
groups:
nuget-minor-and-patch:
update-types: [minor, patch]
nuget:
patterns: ["*"]
ignore:
# These follow the .NET release they ship with; move them with the target framework, not on their own.
- dependency-name: "Microsoft.AspNetCore.*"
update-types: ["version-update:semver-major"]
- dependency-name: "Microsoft.Extensions.*"
update-types: ["version-update:semver-major"]
- dependency-name: "System.*"
update-types: ["version-update:semver-major"]

- package-ecosystem: npm
directory: /
schedule:
interval: weekly
groups:
npm:
patterns: ["*"]

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
groups:
actions:
patterns: ["*"]
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22'
cache: npm

- name: Restore
run: |
Expand Down
95 changes: 29 additions & 66 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# Only two things start it: publishing a GitHub Release, or someone with write access running it by
# hand for an existing tag (to redeploy or roll back). Pull requests never run here.
#
# package GitHub-hosted. Builds and tests the tag, and attaches samelhag.dev-X.Y.Z.zip (plus a .sha256)
# to the release. If the release already has the zip (a redeploy), it reuses it, so the file
# on the release page is always the one that was deployed.
# deploy Self-hosted, `production` environment. Downloads that zip, checks it against the hash the
# package job computed, and copies it into IIS. It checks out no code, builds nothing, and
# gets no repository token.
# package GitHub-hosted, read-only. Publishes the tag (which already passed the required CI check on
# main) and keeps it as a workflow artifact of this run. Nothing is attached to the release,
# which keeps only GitHub's source archives. A redeploy publishes the tag again.
# deploy Self-hosted, `production` environment. Downloads that artifact, checks it against the hash
# the package job computed, and copies it into IIS. It checks out no code, builds nothing,
# and gets no repository token.
name: Deploy

on:
Expand All @@ -33,92 +33,57 @@ jobs:
name: Package release
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: write # attach the build to the release
outputs:
tag: ${{ steps.release.outputs.tag }}
zip: ${{ steps.release.outputs.zip }}
sha256: ${{ steps.hash.outputs.sha256 }}
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
sha256: ${{ steps.package.outputs.sha256 }}
steps:
- name: Resolve release tag
id: release
env:
TAG: ${{ github.event.release.tag_name || inputs.tag }}
run: |
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "Not a release tag: '$TAG'" >&2; exit 1; fi
version="${TAG#v}"
zip="samelhag.dev-$version.zip"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "zip=$zip" >> "$GITHUB_OUTPUT"
if gh release view "$TAG" --json assets --jq '.assets[].name' | grep -qxF "$zip"; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Download the existing release build
if: steps.release.outputs.exists == 'true'
env:
TAG: ${{ steps.release.outputs.tag }}
ASSET: ${{ steps.release.outputs.zip }}
run: gh release download "$TAG" --pattern "$ASSET" --dir dist
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
echo "zip=samelhag.dev-${TAG#v}.zip" >> "$GITHUB_OUTPUT"

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
if: steps.release.outputs.exists == 'false'
with:
ref: refs/tags/${{ steps.release.outputs.tag }}
persist-credentials: false

- uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
if: steps.release.outputs.exists == 'false'
with:
dotnet-version: '10.x'

- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
if: steps.release.outputs.exists == 'false'
with:
node-version: '22'

# The tagged commit already passed CI on main; this checks the exact tree being packaged.
- name: Build, test, and publish
if: steps.release.outputs.exists == 'false'
- name: Publish
env:
VERSION: ${{ steps.release.outputs.version }}
run: |
dotnet restore
dotnet build --no-restore --configuration Release
dotnet test --no-build --configuration Release
node samelhag.dev.Tests/Simulation/validate.cjs
dotnet publish ./samelhag.dev/samelhag.dev.csproj --no-restore --configuration Release --output ./publish -p:Version="$VERSION"
run: dotnet publish ./samelhag.dev/samelhag.dev.csproj --configuration Release --output ./publish -p:Version="$VERSION"

# The file name is in ASSET, not ZIP: Info-ZIP reads a ZIP environment variable as extra options.
- name: Attach the build to the release
if: steps.release.outputs.exists == 'false'
- name: Zip and hash the build
id: package
env:
TAG: ${{ steps.release.outputs.tag }}
ASSET: ${{ steps.release.outputs.zip }}
run: |
mkdir dist
(cd publish && zip -qr "../dist/$ASSET" .)
(cd dist && sha256sum "$ASSET" > "$ASSET.sha256")
gh release upload "$TAG" "dist/$ASSET" "dist/$ASSET.sha256"
echo "sha256=$(sha256sum "dist/$ASSET" | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"

- name: Hash the build
id: hash
env:
ASSET: ${{ steps.release.outputs.zip }}
run: echo "sha256=$(sha256sum "dist/$ASSET" | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: site
path: dist/${{ steps.release.outputs.zip }}
retention-days: 7
if-no-files-found: error

deploy:
name: Deploy to IIS
needs: package
runs-on: [ self-hosted, iis-deploy ]
timeout-minutes: 20
permissions: {} # downloads a public release file; needs no repository access
permissions: {} # the artifact comes from this run; no repository access needed
environment:
name: production
url: https://samelhag.dev
Expand All @@ -129,22 +94,20 @@ jobs:
BACKUP_PATH: C:\inetpub\sites\SamElhagDev.previous
SITE_URL: https://samelhag.dev
steps:
# The hash comes from the package job, not from the release, so a file swapped on the release
# page after packaging fails this check.
- name: Download and verify the release build
# RUNNER_TEMP is emptied at the start of every job, so nothing from an earlier run is left here.
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: site
path: ${{ runner.temp }}/release

# The hash comes from the package job's outputs, so a build changed between the jobs fails here.
- name: Verify and unpack the build
env:
TAG: ${{ needs.package.outputs.tag }}
ASSET: ${{ needs.package.outputs.zip }}
SHA256: ${{ needs.package.outputs.sha256 }}
REPO: ${{ github.repository }}
run: |
$ProgressPreference = 'SilentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$dir = Join-Path $env:RUNNER_TEMP 'release'
if (Test-Path $dir) { Remove-Item $dir -Recurse -Force }
New-Item -ItemType Directory $dir | Out-Null
$zip = Join-Path $dir $env:ASSET
Invoke-WebRequest -Uri "https://github.com/$env:REPO/releases/download/$env:TAG/$env:ASSET" -OutFile $zip -UseBasicParsing
$actual = (Get-FileHash $zip -Algorithm SHA256).Hash.ToLowerInvariant()
if ($actual -ne $env:SHA256) { throw "Checksum mismatch for $($env:ASSET): expected $env:SHA256, got $actual" }
Expand-Archive $zip -DestinationPath (Join-Path $dir 'publish')
Expand Down
31 changes: 28 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ All notable changes to samelhag.dev. Versions follow [Semantic Versioning](https
website: a major version removes or renames URLs (or is a redesign), a minor version adds something visitors
can see, and a patch fixes something.

## 1.0.1 (2026-11-29)

Dependency updates and a leaner deploy. Nothing visitors see changes.

### Security and dependencies

- **MailKit 5.0:** the contact form's email library now uses `MimeKit.Core` and no longer depends on
BouncyCastle, so the cryptography stack it pulled in (and the `System.Security.Cryptography.Pkcs` pin that
patched it) is gone. The SMTP code needed one `using` for the new send API.
- **Updated:** MudBlazor 9.14, OpenTelemetry 1.21, Microsoft.Extensions.Http.Resilience and ServiceDiscovery
10.11.1, Microsoft.NET.Test.Sdk 18.12, coverlet 10.1.1, xunit runner 3.1.5, ReportGenerator 5.6.1, and
TypeScript 7.0 for the JavaScript type check.
- **Scanned:** no known vulnerabilities in any NuGet package (including transitive ones) or npm package.
- **Dependabot alerts and security updates** are now on. Weekly updates arrive as one grouped pull request per
ecosystem, and major versions of packages tied to the .NET version are skipped.

### Releases and deployment

- **Releases carry only the source archives.** The build goes from the package job to the deploy job as a
workflow artifact of the run, checked against its SHA-256, instead of being attached to the release.
- **Leaner packaging:** the package job publishes the tag without building and testing it a second time,
since the same commit already passed the required CI check on `main`. The workflow no longer needs write
access to the repository.
- **CI** caches npm downloads.

## 1.0.0 (2026-11-29)

The first versioned release. It covers the site as it stands after the audit overhaul, the security work,
Expand Down Expand Up @@ -53,9 +78,9 @@ and a code-quality pass, and it starts versioned releases with notes for every d
on GitHub-hosted runners, so code from a pull request never runs on the production server; workflow runs for
outside contributors need approval.
- **Coverage:** tests report line and branch coverage, posted as a comment on each pull request.
- **Releases deploy:** publishing a GitHub Release (`vX.Y.Z`) builds and tests the tag on a GitHub-hosted runner,
attaches the build to the release as `samelhag.dev-X.Y.Z.zip` (with a SHA-256), and deploys that exact file.
Any earlier release can be redeployed by hand. The production server only downloads and verifies the zip;
- **Releases deploy:** publishing a GitHub Release (`vX.Y.Z`) builds and tests the tag on a GitHub-hosted runner
and deploys that build, checked against its SHA-256. Any earlier release can be redeployed by hand. The
production server only downloads and verifies the build;
the backup, smoke test (now including `/sitemap.xml`), and automatic rollback are unchanged.
- **Workflow hardening:** every action pinned to a commit SHA, read-only tokens, and a `production`
environment that only accepts `main` and release tags.
Expand Down
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ dotnet run --project samelhag.dev.AppHost # same site plus the Aspire dashboard
don't need a release.
- **To release:** set `<Version>` in `Directory.Build.props` and add a `CHANGELOG.md` entry in the pull request, then
after it merges, publish a GitHub Release tagged `vX.Y.Z` on the merge commit with that entry as its notes.
Publishing is what deploys: `deploy.yml` attaches `samelhag.dev-X.Y.Z.zip` to the release and deploys that file.
Publishing is what deploys: `deploy.yml` builds the tag, passes it to the deploy job as a run artifact, and deploys
it. Releases carry only GitHub's source archives.
- **Workflow security** (the repository is public and the deploy runner is the production server):
- Pull request workflows run on GitHub-hosted runners only. Never give a `pull_request` job `runs-on: self-hosted`,
and never use `pull_request_target`.
- Only `deploy.yml`'s deploy job uses the self-hosted runner (`[self-hosted, iis-deploy]`, environment `production`),
and it only downloads and verifies the release zip. Building and packaging happen on GitHub-hosted runners.
and it only downloads and verifies the run's build artifact. Building and packaging happen on GitHub-hosted runners.
- Anything a pull request run produces (artifacts, coverage) is data: never run it, and never deploy it.
- Pin actions to a full commit SHA with the version in a comment; Dependabot updates them.

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Settings shared by every project in the solution. -->
<PropertyGroup>
<!-- Site version (SemVer). Release notes for each version are in CHANGELOG.md and on GitHub Releases. -->
<Version>1.0.0</Version>
<Version>1.0.1</Version>

<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
Expand Down
26 changes: 12 additions & 14 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@
</PropertyGroup>

<ItemGroup Label="Web app">
<PackageVersion Include="MailKit" Version="4.17.0" />
<PackageVersion Include="MudBlazor" Version="9.6.0" />
<!-- Transitive via MailKit/MimeKit; pinned past 10.0.0 for GHSA-846f-f764-76mx and GHSA-2fmv-rv2c-59x7. -->
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="10.0.15" />
<PackageVersion Include="MailKit" Version="5.0.0" />
<PackageVersion Include="MudBlazor" Version="9.14.0" />
</ItemGroup>

<ItemGroup Label="Service defaults and telemetry">
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="10.7.0" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="10.7.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.16.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.16.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.16.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.16.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.15.1" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="10.11.1" />
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="10.11.1" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.21.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.21.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.21.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.21.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.21.0" />
</ItemGroup>

<ItemGroup Label="Aspire AppHost">
Expand All @@ -27,11 +25,11 @@
</ItemGroup>

<ItemGroup Label="Tests">
<PackageVersion Include="coverlet.collector" Version="10.1.0" />
<PackageVersion Include="coverlet.collector" Version="10.1.1" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.15" />
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="11.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.4" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>
</Project>
Loading