Improved: ConfigService now clones ItemsByFolder to avoid issues with… #876
Workflow file for this run
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: Build and Publish | |
on: | |
push: | |
branches: | |
- '*' | |
tags: | |
- '*' | |
pull_request: | |
branches: [ master ] | |
workflow_dispatch: | |
env: | |
TOOLS_PATH: ./source/Publish/Tools.zip | |
PUBLISH_CHOCO_PATH: ./source/Publish/Chocolatey | |
PUBLISH_INSTALLER_PATH: ./source/Publish/Installer/Setup.exe | |
PUBLISH_INSTALLER_STATIC_PATH: ./source/Publish/Installer-Static/Setup-Linux.exe | |
PUBLISH_CHANGELOG_PATH: ./source/Publish/Changelog.md | |
PUBLISH_PACKAGES_PATH: ./source/Publish/Packages | |
PUBLISH_RELEASE_FOLDER: ./source/Publish/Release | |
PUBLISH_RELEASE_PATH: ./source/Publish/Release/Release.zip | |
PUBLISH_PATH: ./source/Publish | |
IS_RELEASE: ${{ startsWith(github.ref, 'refs/tags/') }} | |
RELEASE_TAG: ${{ github.ref_name }} | |
jobs: | |
build: | |
runs-on: windows-2022 | |
defaults: | |
run: | |
shell: pwsh | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
submodules: 'recursive' | |
- name: Print Environment Variables | |
run: | | |
echo "Changelog Path: $env:PUBLISH_CHANGELOG_PATH" | |
echo "Publish Path: $env:PUBLISH_PATH" | |
echo "Is Release?: $env:IS_RELEASE" | |
echo "Release Tag: $env:RELEASE_TAG" | |
# Required for C#10 features. | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '14' | |
- name: Setup MSVC | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Clear MSVC Redundant Environment Variables | |
run: echo "Platform=" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append | |
- name: Setup AutoChangelog | |
run: npm install -g auto-changelog | |
- name: Setup Dotnet SDK (5.0) | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '5.0.x' | |
- name: Setup Dotnet SDK (7.0) | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '7.0.x' | |
- name: Setup Dotnet SDK (8.0) | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Setup Dotnet SDK (9.0) | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '9.0.x' | |
- name: Get Dotnet Info | |
run: dotnet --info | |
- name: Publish | |
run: | | |
if ($env:IS_RELEASE -eq 'true') | |
{ | |
.\source\Publish.ps1 -Version "$env:RELEASE_TAG" | |
} | |
else | |
{ | |
.\source\Publish.ps1 -Version "1.0.0-$(git rev-parse --short "$env:GITHUB_SHA")" | |
} | |
- name: Inject Version (on Tag) | |
if: env.IS_RELEASE == 'true' | |
run: | | |
echo "$env:RELEASE_TAG" > "version.txt" | |
Compress-Archive -update "version.txt" "$env:PUBLISH_RELEASE_PATH" | |
- name: Create NuGet Package Artifacts | |
run: | | |
[System.IO.Directory]::CreateDirectory("$env:PUBLISH_PACKAGES_PATH") | |
$items = Get-ChildItem -Path "." -Recurse | Where-Object { $_.Name -match "^Reloaded\..*\.nupkg" } | |
foreach ($item in $items) | |
{ | |
Write-Host "Moving $item -> $env:PUBLISH_PACKAGES_PATH" | |
Move-Item -Path "$item" -Destination "$env:PUBLISH_PACKAGES_PATH" | |
} | |
- name: Create Changelog (on Tag) | |
run: | | |
[System.IO.Directory]::CreateDirectory("$env:PUBLISH_PATH") | |
if ($env:IS_RELEASE -eq 'true') | |
{ | |
auto-changelog --sort-commits date --hide-credit --template changelog-template.hbs --commit-limit false --starting-version "$env:RELEASE_TAG" --output "$env:PUBLISH_CHANGELOG_PATH" | |
} | |
else | |
{ | |
auto-changelog --sort-commits date --hide-credit --template changelog-template.hbs --commit-limit false --unreleased --output "$env:PUBLISH_CHANGELOG_PATH" | |
} | |
- name: Upload Chocolatey Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
# Artifact name | |
name: Chocolatey Package | |
# A file, directory or wildcard pattern that describes what to upload | |
path: ${{ env.PUBLISH_CHOCO_PATH }}/* | |
retention-days: 0 | |
- name: Upload Reloaded Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
# Artifact name | |
name: Loader Build | |
# A file, directory or wildcard pattern that describes what to upload | |
path: ${{ env.PUBLISH_RELEASE_PATH }} | |
retention-days: 0 | |
- name: Upload Installer Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
# Artifact name | |
name: Installer | |
# A file, directory or wildcard pattern that describes what to upload | |
path: | | |
${{ env.PUBLISH_INSTALLER_PATH }} | |
${{ env.PUBLISH_INSTALLER_STATIC_PATH }} | |
retention-days: 0 | |
- name: Upload NuGet Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
# Artifact name | |
name: NuGet Packages | |
# A file, directory or wildcard pattern that describes what to upload | |
path: ${{ env.PUBLISH_PACKAGES_PATH }}/* | |
retention-days: 0 | |
- name: Upload Changelog Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
# Artifact name | |
name: Changelog | |
# A file, directory or wildcard pattern that describes what to upload | |
path: ${{ env.PUBLISH_CHANGELOG_PATH }} | |
retention-days: 0 | |
- name: Upload Tools Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
# Artifact name | |
name: Tools | |
# A file, directory or wildcard pattern that describes what to upload | |
path: ${{ env.TOOLS_PATH }} | |
retention-days: 0 | |
- name: Test | |
run: dotnet test -c Release ./source/Reloaded.Mod.Loader.Tests/Reloaded.Mod.Loader.Tests.csproj | |
- name: Upload to GitHub Releases | |
uses: softprops/action-gh-release@v2 | |
if: env.IS_RELEASE == 'true' | |
with: | |
# Path to load note-worthy description of changes in release from | |
body_path: ${{ env.PUBLISH_CHANGELOG_PATH }} | |
# Newline-delimited list of path globs for asset files to upload | |
files: | | |
${{ env.PUBLISH_RELEASE_FOLDER }}/* | |
${{ env.TOOLS_PATH }} | |
${{ env.PUBLISH_INSTALLER_PATH }} | |
${{ env.PUBLISH_INSTALLER_STATIC_PATH }} | |
- name: Upload to NuGet (on Tag) | |
env: | |
NUGET_KEY: ${{ secrets.NUGET_KEY }} | |
if: env.IS_RELEASE == 'true' | |
run: | | |
$items = Get-ChildItem -Path "$env:PUBLISH_PACKAGES_PATH/*.nupkg" | |
Foreach ($item in $items) | |
{ | |
Write-Host "Pushing $item" | |
dotnet nuget push "$item" -k "$env:NUGET_KEY" -s "https://api.nuget.org/v3/index.json" --skip-duplicate | |
} |