diff --git a/.github/workflows/tagged-release.yml b/.github/workflows/tagged-release.yml new file mode 100644 index 00000000..e775bffa --- /dev/null +++ b/.github/workflows/tagged-release.yml @@ -0,0 +1,114 @@ +name: Tagged Release +on: + push: + tags: + - 'v*' +jobs: + build-and-release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + fetch-tags: true + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + + - uses: dotnet/nbgv@master + id: nbgv + + - name: Display Package Version + run: echo "PackageVersion=${{ steps.nbgv.outputs.SemVer2 }}" + + - name: Validate Package Version Matches Tag + run: | + # Extract version from tag (remove 'v' prefix if present) + TAG_VERSION="${{ github.ref_name }}" + TAG_VERSION="${TAG_VERSION#v}" + + # Extract version from code + CODE_VERSION="${{ steps.nbgv.outputs.SemVer2 }}" + + echo "Tag version: $TAG_VERSION" + echo "Code version: $CODE_VERSION" + + # Compare versions + if [ "$TAG_VERSION" != "$CODE_VERSION" ]; then + echo "Error: Version mismatch between tag ($TAG_VERSION) and code ($CODE_VERSION)" + echo "Please make sure the PackageVersion in code is the same as the tag name" + exit 1 + else + echo "✓ Versions match!" + fi + + - name: Restore dependencies + run: dotnet restore src/IdentityServer8.sln + - name: Build + run: dotnet build src/IdentityServer8.sln --configuration Release --no-restore + - name: Test + run: dotnet test src/IdentityServer8.sln --configuration Release --no-build + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + env: + token: ${{ secrets.CODECOV_TOKEN }} + slug: alexhiggins732/IdentityServer8 + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + # Add step to pack NuGet packages + - name: Pack NuGet Packages + run: dotnet pack src/IdentityServer8.sln --configuration Release --no-build -o nuget -p:PackageVersion=${{ steps.nbgv.outputs.SemVer2 }} + + # Package binaries as before + - name: Package Artifacts + run: dotnet publish src/IdentityServer8.sln --configuration Release --no-build -o out + - name: Zip Artifacts + run: Compress-Archive -Path ./out/* -DestinationPath ./identityserver8_binaries.zip + shell: pwsh + + # Create a zip of NuGet packages for the release + - name: Zip NuGet Packages + run: Compress-Archive -Path ./nuget/*.nupkg -DestinationPath ./identityserver8_nuget_packages.zip + shell: pwsh + + - name: Create Release + if: ${{ success() }} + id: create_release + uses: actions/create-release@v1 + with: + tag_name: ${{ github.ref_name }} + release_name: IdentityServer 8 Release ${{ github.ref_name }} + body: This is an automated release for ${{ github.ref_name }} + draft: false + prerelease: ${{ contains(github.ref_name, '-') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Upload binaries as before + - name: Upload Binaries + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./identityserver8_binaries.zip + asset_name: identityserver8_binaries.zip + asset_content_type: application/zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Upload NuGet packages to release + - name: Upload NuGet Packages + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./identityserver8_nuget_packages.zip + asset_name: identityserver8_nuget_packages.zip + asset_content_type: application/zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # Push packages to NuGet.org + - name: Push to NuGet.org + run: dotnet nuget push ./nuget/*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} \ No newline at end of file diff --git a/README.md b/README.md index 926913cf..87a31757 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,21 @@ Active development happens on the main branch. This always contains the latest v * Clone this repo * Run `dotnet build src/identityserver8.slm` or `build.sh` in the root of the cloned repo. +## Release Process +When you push a commit with a tag matching a semantic version (e.g., v1.0.0) to the repo, an automated workflow will trigger to build, test, and publish a GitHub release with compiled binaries and nuget packages. + +Please ensure you have updated all of the version files below with the release version number, as the tagged release workflow will validate the version in code matches the tag:- + +- Directory.Build.props +- version.json +- docs/conf.py + +To create the tag use (e.g. for v8.0.5): +``` +git tag -a v8.0.5 -m "IdentityServer8 Release v8.0.5" +git push origin v8.0.5` +``` + ## Documentation For project documentation, please visit [readthedocs](https://IdentityServer8.readthedocs.io). diff --git a/global.json b/global.json index f3365c41..75a80e90 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,6 @@ { "sdk": { - "version": "8.0.100" + "version": "8.0.0", + "rollForward": "latestMinor" } } \ No newline at end of file