Alterations to release workflow #22
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: Release new version | |
on: | |
push: | |
tags: | |
- v*.*.* | |
env: | |
# Path to the solution file relative to the root of the project. | |
SOLUTION_FILE_PATH: ./SaveDataParser.vcxproj | |
BUILD_CONFIGURATION: Release | |
BUILD_PLATFORM: x64 | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Lookup commits since last release | |
id: changes | |
uses: simbo/changes-since-last-release-action@v1 | |
- name: Create environment variables | |
run: | | |
$versionPrefix = "refs/tags/v" | |
$version = $env:GITHUB_REF.Substring($versionPrefix.Length) | |
$commitSha = (git rev-parse --short $env:GITHUB_SHA) | |
$changes = ${{ steps.changes.outputs.log }} | |
echo "NGPLUS_COMMIT_SHA=${commitSha}" | Out-File -FilePath $env:GITHUB_ENV -Encoding UTF8 -Append | |
echo "NGPLUS_VERSION=${version}" | Out-File -FilePath $env:GITHUB_ENV -Encoding UTF8 -Append | |
echo "NGPLUS_COMMITS_SINCE_LAST_TAG=${changes} | Out-File -FilePath $env:GITHUB_ENV -Encoding UTF8 -Append" | |
- name: Add MSBuild to PATH | |
uses: microsoft/[email protected] | |
- name: Restore NuGet packages | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
run: nuget restore ${{env.SOLUTION_FILE_PATH}} | |
- name: Build | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{env.BUILD_PLATFORM}} ${{env.SOLUTION_FILE_PATH}} | |
- name: Prepare ZIP | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
run: | | |
$packagingDir = "./_packaging" | |
# Create the necessary directories | |
New-Item -ItemType directory -Path $packagingDir/red4ext | |
New-Item -ItemType directory -Path $packagingDir/red4ext/plugins | |
New-Item -ItemType directory -Path $packagingDir/red4ext/plugins/NewGamePlus | |
New-Item -ItemType directory -Path $packagingDir/red4ext/plugins/NewGamePlus/redscript | |
New-Item -ItemType directory -Path $packagingDir/red4ext/plugins/NewGamePlus/tweaks | |
# Copy the build artifacts | |
Copy-Item -Path ./x64/Release/NewGamePlus.dll -Destination $packagingDir/red4ext/plugins/NewGamePlus | |
Copy-Item -Path ./x64/Release/NewGamePlus.pdb -Destination $packagingDir/red4ext/plugins/NewGamePlus | |
# Copy over Redscript/tweaks | |
Copy-Item -Path ./scripting/* -Destination $packagingDir/red4ext/plugins/NewGamePlus/redscript -Recurse | |
Copy-Item -Path ./tweaks/* -Destination $packagingDir/red4ext/plugins/NewGamePlus/tweaks -Recurse | |
# Copy over archive and .xl file (TODO: pack .archive dynamically) | |
Copy-Item -Path ./wolvenkit/packed/archive/pc/mod/NewGamePlus.archive -Destination $packagingDir/red4ext/plugins/NewGamePlus | |
Copy-Item -Path ./wolvenkit/packed/archive/pc/mod/NewGamePlus.archive.xl -Destination $packagingDir/red4ext/plugins/NewGamePlus | |
# Copy the license and third-party licenses | |
Copy-Item -Path ./LICENSE -Destination $packagingDir/red4ext/plugins/NewGamePlus/LICENSE | |
Copy-Item -Path ./THIRDPARTY_LICENSES -Destination $packagingDir/red4ext/plugins/NewGamePlus/THIRD_PARTY_LICENSES | |
# Create the ZIP file. | |
7z a NewGamePlus_${env:NGPLUS_VERSION}.zip $packagingDir/* | |
- name: Generate hash for .zip | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
run: | | |
$hash = Get-FileHash -Algorithm SHA256 -Path NewGamePlus_${env:NGPLUS_VERSION}.zip | |
$hash | Format-List | |
$only_hash = $hash | ForEach-Object { $_.Hash } | |
echo "NGPLUS_SHA256=${only_hash}" | Out-File -FilePath $env:GITHUB_ENV -Encoding UTF8 -Append | |
- name: Upload build to releases | |
uses: softprops/[email protected] | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
with: | |
append_body: true | |
body: | | |
### SHA256 of release: | |
- ${{env.NGPLUS_SHA256}} | |
### Commits | |
- ${{env.NGPLUS_COMMITS_SINCE_LAST_TAG}} | |
files: | | |
NewGamePlus_${{env.NGPLUS_VERSION }}.zip |