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
38 changes: 23 additions & 15 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: .NET
on:
push:
branches: [ "master" ]
tags: [ "v*" ]
tags: [ "*" ]
pull_request:
branches: [ "master" ]

Expand All @@ -12,38 +12,46 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x

- uses: gittools/actions/gitversion/setup@v3
- id: gitversion
uses: gittools/actions/gitversion/execute@v3

- name: Restore dependencies
run: dotnet restore

- name: Determine package version
id: version
shell: bash
run: |
if [ "$GITHUB_REF_TYPE" = "tag" ]; then
echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
else
echo "version=0.1.0-ci.${GITHUB_RUN_NUMBER}" >> "$GITHUB_OUTPUT"
fi

- name: Build
run: dotnet build --no-restore --configuration Release /p:Version=${{ steps.version.outputs.version }}
run: dotnet build --no-restore --configuration Release

- name: Test
run: dotnet test --no-build --verbosity normal --configuration Release

- name: Pack
run: dotnet pack MakeInterface.Generator/MakeInterface.Generator.csproj --no-build --configuration Release /p:PackageVersion=${{ steps.version.outputs.version }} -o ./artifacts
run: >
dotnet pack MakeInterface.Generator/MakeInterface.Generator.csproj
--no-build -c Release
/p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }}
-o ./artifacts

- name: Publish prerelease to GitHub Packages
if: github.event_name == 'push' && github.ref_type == 'branch'
run: dotnet nuget push ./artifacts/MakeInterface.Generator.${{ steps.version.outputs.version }}.nupkg --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
run: >
dotnet nuget push
./artifacts/MakeInterface.Generator.${{ steps.gitversion.outputs.nuGetVersionV2 }}.nupkg
--source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
--api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate

- name: Publish release to NuGet.org
if: github.ref_type == 'tag'
run: dotnet nuget push ./artifacts/MakeInterface.Generator.${{ steps.version.outputs.version }}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
run: >
dotnet nuget push
./artifacts/MakeInterface.Generator.${{ steps.gitversion.outputs.nuGetVersionV2 }}.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
6 changes: 6 additions & 0 deletions .gitversion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mode: ContinuousDeployment
branches:
master:
regex: ^master$
label: ''
commit-message-incrementing: Enabled
5 changes: 4 additions & 1 deletion MakeInterface.Generator/MakeInterface.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<OutputType>library</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>MakeInterface.Generator</PackageId>
<Version>1.0.0</Version>
<Authors>Frederik Tegnander</Authors>
<Company>COWI</Company>
<PackageTags>Interfaces;SourceGenerator;MakeInterface</PackageTags>
Expand Down Expand Up @@ -44,6 +43,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="6.*">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
14 changes: 6 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,15 @@ dotnet add package MakeInterface.Generator
```

The `GenerateInterface` attribute is included in the package and will be available after the build without adding any extra references.
Install the NuGet package [MakeInterface](https://www.nuget.org/packages/MakeInterface.Generator/):

```bash
dotnet add package MakeInterface.Generator
```

The `GenerateInterface` attribute is included in the package and will be available after the build without adding any extra references.
## Versioning
This repository uses [GitVersion](https://gitversion.net/) in **Continuous Deployment** mode.
Every build calculates a deterministic SemVer 2.0 version from the Git history.
Local builds and CI therefore produce identical package and assembly versions.


## License
MIT
## Release process
- Pushes to the `master` branch publish prerelease packages to GitHub Packages using versions like `0.1.0-ci.<run number>`.
- Tagging the repository with `v<version>` automatically publishes that version to NuGet.org if `NUGET_API_KEY` is configured.
- Pushes to `master` publish prerelease packages to GitHub Packages using the version calculated by GitVersion.
- Tagging the repository publishes the tagged version to NuGet.org when `NUGET_API_KEY` is configured.