add comments #4
Workflow file for this run
This file contains hidden or 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: Build and Release Extension | |
on: | |
push: | |
tags: | |
- 'v*' # Matches v1.6.0, v2.0, etc. | |
permissions: | |
contents: write | |
jobs: | |
build-and-release: | |
runs-on: windows-latest # Required for .NET Framework | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Build with MSBuild | |
shell: pwsh | |
run: | | |
& "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" LocalLibrary.sln /p:Configuration=Release | |
- name: Set variables | |
id: vars | |
shell: pwsh | |
run: | | |
$tag = "${{ github.ref_name }}" # e.g., v1.6.0 | |
$versiondots = $tag.TrimStart("v") | |
$version = $versiondots -replace ".", "_" | |
echo "TAG=$tag" >> $env:GITHUB_ENV | |
echo "VERSION=$version" >> $env:GITHUB_ENV | |
echo "VERSIONDOTS=$versiondots" >> $env:GITHUB_ENV | |
echo "OUTFILE=LocalLibrary_2d01017d-024e-444d-80d3-f62f5be3fca5_$version.pext" >> $env:GITHUB_ENV | |
- name: Update extension.yaml version | |
shell: pwsh | |
run: | | |
(Get-Content extension.yaml) ` | |
-replace '^(Version:\s*).+$', "Version: $env:VERSIONDOTS" ` | |
| Set-Content extension.yaml | |
- name: Prepare release package | |
shell: pwsh | |
run: | | |
New-Item -ItemType Directory -Force -Path package | |
$buildOutput = Get-ChildItem -Path . -Recurse -Filter LocalLibrary.dll | Where-Object { $_.FullName -like '*\bin\Release\*' } | Select-Object -First 1 | |
$pdbOutput = Get-ChildItem -Path . -Recurse -Filter LocalLibrary.pdb | Where-Object { $_.FullName -like '*\bin\Release\*' } | Select-Object -First 1 | |
if ($null -eq $buildOutput -or $null -eq $pdbOutput) { | |
Write-Error "Could not find LocalLibrary.dll or LocalLibrary.pdb" | |
exit 1 | |
} | |
Copy-Item $buildOutput.FullName -Destination package/ | |
Copy-Item $pdbOutput.FullName -Destination package/ | |
Copy-Item extension.yaml -Destination package/ | |
Copy-Item icon.png -Destination package/ | |
Compress-Archive -Path package\* -DestinationPath $env:OUTFILE -CompressionLevel Optimal | |
- name: Append to LocalLibraryManifest.yaml | |
shell: pwsh | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Required for gh CLI | |
run: | | |
$version = $env:VERSION | |
$tag = $env:TAG | |
$releaseDate = (Get-Date -Format 'yyyy-MM-dd') | |
# Download release notes using GitHub CLI | |
$notes = gh api repos/${{ github.repository }}/releases/tags/$tag | ConvertFrom-Json | |
$changes = $notes.body -split "`n" | ForEach-Object { " - $_" } | |
# Compose manifest block | |
$block = @" | |
- Version: $version | |
RequiredApiVersion: 6.11.0 | |
ReleaseDate: $releaseDate | |
PackageUrl: https://github.com/azuravian/playnite-LocalLibrary/releases/download/$tag/LocalLibrary_2d01017d-024e-444d-80d3-f62f5be3fca5_$version.pext | |
Changelog: | |
$($changes -join "`n") | |
"@ | |
# debug | |
Write-Host "Appended manifest block:" | |
Write-Host $block | |
# Append to manifest file | |
Add-Content "manifests/LocalLibraryManifest.yaml" $block | |
- name: Create GitHub release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: ${{ env.OUTFILE }} | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Commit manifest update | |
shell: pwsh | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add manifests/LocalLibraryManifest.yaml | |
git commit -m "Update manifest for $env:VERSIONDOTS" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |