release #84
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: release | |
on: | |
workflow_dispatch: | |
inputs: | |
ver: | |
description: 'The version number, should be specified as a semantic version e.g: X.Y.Z' | |
required: true | |
release-notes: | |
description: 'The versions release notes' | |
required: true | |
permissions: | |
contents: read | |
env: | |
DOTNET_VERSION: '8.0' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
repository: benpollarduk/NetAF | |
token: ${{ secrets.PAT }} | |
- name: Setup environment | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Install dependencies | |
run: dotnet restore | |
- name: Install node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Update docfx | |
run: dotnet tool update -g docfx | |
- name: Update version and release notes in csproj file | |
run: | | |
echo "Version: ${{ inputs.ver }}" | |
echo "Release notes: ${{ inputs.release-notes }}" | |
# update the .csproj file with the input version | |
sed -i "s/<Version>.*<\/Version>/<Version>${{ inputs.ver }}<\/Version>/" NetAF/NetAF.csproj | |
sed -i "s/<AssemblyVersion>.*<\/AssemblyVersion>/<AssemblyVersion>${{ inputs.ver }}.0<\/AssemblyVersion>/" NetAF/NetAF.csproj | |
sed -i "s/<FileVersion>.*<\/FileVersion>/<FileVersion>${{ inputs.ver }}<\/FileVersion>/" NetAF/NetAF.csproj | |
# update the .csproj file with the release notes | |
sed -i "s/<PackageReleaseNotes>.*<\/PackageReleaseNotes>/<PackageReleaseNotes>${{ inputs.release-notes }}<\/PackageReleaseNotes>/" NetAF/NetAF.csproj | |
- name: Build | |
run: dotnet build -c Release | |
- name: Run tests with coverlet | |
run: dotnet test /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov | |
- name: Tag the commit | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git tag -a "${{ inputs.ver }}" -m "${{ inputs.ver }} tagged during GitHub action" | |
git push --tags | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v3 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
- name: Push NuGet package (GitHub) | |
run: | | |
dotnet nuget push ./NetAF/bin/Release/*.nupkg --api-key ${{ secrets.PAT }} --source https://nuget.pkg.github.com/benpollarduk/index.json | |
- name: Push NuGet package (NuGet.org) | |
run: | | |
dotnet nuget push ./NetAF/bin/Release/*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json | |
- name: Build documentation | |
run: docfx docs/docfx/docfx.json | |
- name: Copy website files, commit and tag, then push changes to NetAF-docs | |
run: | | |
mkdir NetAF-docs | |
cd NetAF-docs | |
git init | |
git remote add origin https://${{ secrets.PAT }}@github.com/benpollarduk/NetAF-docs.git | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git fetch | |
git checkout main | |
git rm -r --ignore-unmatch . | |
cp -r ../docs/docfx/_site/* . | |
git add . | |
git commit -m "Update documentation" | |
git tag -a "${{ inputs.ver }}" -m "${{ inputs.ver }} tagged during GitHub action" | |
git push --follow-tags https://${{ secrets.PAT }}@github.com/benpollarduk/NetAF-docs.git HEAD:main | |
- name: Create GitHub release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: "${{ inputs.ver }}" | |
release_name: "${{ inputs.ver }}" | |
body: "${{ inputs.release-notes }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} |