Skip to content

release

release #26

Workflow file for this run

name: release
on:
workflow_dispatch:
branches:
- main
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: windows-2022
steps:
- name: Restrict to owner
if: github.actor != 'benpollarduk'
run: |
echo "Access denied for user ${{ github.actor }}"
exit 1
- name: Checkout repository
uses: actions/checkout@v3
with:
repository: benpollarduk/lofieffects.wpf
token: ${{ secrets.PAT }}
- name: Setup environment
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install dependencies
run: dotnet restore
- name: Update version and release notes in csproj file
shell: pwsh # Use PowerShell for the step
run: |
echo "Version: ${{ inputs.ver }}"
echo "Release notes: ${{ inputs.release-notes }}"
# Update the .csproj file with the input version
$csprojPath = "LoFiEffects.WPF/LoFiEffects.WPF.csproj"
(Get-Content $csprojPath) -replace '<Version>.*</Version>', "<Version>${{ inputs.ver }}</Version>" |
Set-Content $csprojPath
(Get-Content $csprojPath) -replace '<AssemblyVersion>.*</AssemblyVersion>', "<AssemblyVersion>${{ inputs.ver }}.0</AssemblyVersion>" |
Set-Content $csprojPath
(Get-Content $csprojPath) -replace '<FileVersion>.*</FileVersion>', "<FileVersion>${{ inputs.ver }}</FileVersion>" |
Set-Content $csprojPath
# Update the .csproj file with the release notes
(Get-Content $csprojPath) -replace '<PackageReleaseNotes>.*</PackageReleaseNotes>', "<PackageReleaseNotes>${{ inputs.release-notes }}</PackageReleaseNotes>" |
Set-Content $csprojPath
- 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 .\LoFiEffects.WPF\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 .\LoFiEffects.WPF\bin\Release\*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json
- 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 }}