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
23 changes: 19 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Release

# Publishing is explicit: push a tag matching the <Version> in
# src/Directory.Build.props (e.g. v3.0.0) after the bump is merged to main.
on:
push:
branches: [ "main" ]
workflow_dispatch:
tags: [ "v[0-9]+.[0-9]+.[0-9]+*" ]

# Use the built-in GITHUB_TOKEN to publish to GitHub Packages —
# no personal access token to manage or rotate.
Expand All @@ -12,12 +13,15 @@ permissions:
packages: write

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

jobs:
publish:
runs-on: ubuntu-latest
env:
# Keeps the first-run banner out of the version captured below.
DOTNET_NOLOGO: true

steps:
- name: Checkout
Expand All @@ -28,6 +32,15 @@ jobs:
with:
dotnet-version: 8.0.x

- name: Check tag matches project version
run: |
project_version=$(dotnet msbuild src/Authorization.Abstractions -getProperty:Version)
tag_version="${GITHUB_REF_NAME#v}"
if [ "$project_version" != "$tag_version" ]; then
echo "::error::Tag $GITHUB_REF_NAME does not match project version $project_version"
exit 1
fi

- name: Restore
run: dotnet restore Authorization.sln

Expand All @@ -48,9 +61,11 @@ jobs:
retention-days: 7
path: ${{ github.workspace }}/artifacts/*.nupkg

# No --skip-duplicate: republishing an existing version must fail loudly.
# GitHub Packages does not accept .snupkg symbol packages.
- name: Push to GitHub Packages
run: >
dotnet nuget push "${{ github.workspace }}/artifacts/*.nupkg"
--api-key ${{ secrets.GITHUB_TOKEN }}
--source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
--skip-duplicate
--no-symbols
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,15 @@ dotnet build Authorization.sln -c Release
dotnet test Authorization.sln -c Release
```

CI runs on every push and pull request; packages are published from the `main` branch.
CI runs on every push and pull request.

To release, bump `<Version>` in `src/Directory.Build.props` through a PR, then tag the merged commit on `main`:

```bash
git tag v3.0.0 && git push origin v3.0.0
```

The release workflow fails if the tag does not match the project version or the version already exists on the feed.

---

Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<NoWarn>$(NoWarn);CS1591</NoWarn>
</PropertyGroup>

<!-- Common NuGet metadata (v2.0.0 = breaking English API rename). -->
<!-- Common NuGet metadata. Releases are published by pushing a matching vX.Y.Z tag. -->
<PropertyGroup>
<Version>2.0.0</Version>
<Version>3.0.0</Version>
<Authors>Isma-L154</Authors>
<Company>Isma-L154</Company>
<Product>JWT Authorization Middleware</Product>
Expand Down
Loading