Publish Version #6
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: Publish Version | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install Chocolatey | |
run: | | |
Set-ExecutionPolicy Bypass -Scope Process -Force; ` | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; ` | |
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | |
shell: pwsh | |
- name: Install NASM | |
run: choco install nasm -y | |
shell: cmd | |
- name: Setup Visual studio | |
uses: microsoft/setup-msbuild@v2 | |
- name: Extract and increment version number | |
id: increment_version | |
run: | | |
$filePath = "AmethystRuntime/CMakeLists.txt" | |
$version_line = Select-String -Path $filePath -Pattern 'set\(MOD_VERSION "(.*)"\)' | |
if ($version_line -match 'set\(MOD_VERSION "(\d+)\.(\d+)\.(\d+)"\)') { | |
$major = [int]$matches[1] | |
$minor = [int]$matches[2] | |
$patch = [int]$matches[3] | |
# Increment the minor version | |
$new_patch = $patch + 1 | |
$new_version = "$major.$minor.$new_patch" | |
# Update the CMakeLists.txt file | |
(Get-Content $filePath) -replace 'set\(MOD_VERSION ".*"\)', "set(MOD_VERSION `"$new_version`")" | Set-Content $filePath | |
echo "NEW_VERSION=$new_version" >> $env:GITHUB_ENV | |
echo "FILE_PATH=$filePath" >> $env:GITHUB_ENV | |
} else { | |
Write-Error "Version line not found or does not match the expected format." | |
exit 1 | |
} | |
shell: pwsh | |
- name: Push bumped version | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add $env:FILE_PATH | |
git commit -m "Bump version to $env:NEW_VERSION" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: pwsh | |
- name: Build AmethystRuntime | |
run: | | |
mkdir build | |
cd build | |
cmake -DCI_CD_BUILD=ON .. | |
msbuild Amethyst.sln | |
- name: Package Build | |
run: | | |
$version = $env:NEW_VERSION | |
$sourcePath = "dist/AmethystRuntime@$version" | |
$zipPath = "dist/AmethystRuntime@$version.zip" | |
if (-Not (Test-Path -Path $sourcePath)) { | |
Write-Error "Source path does not exist: $sourcePath" | |
exit 1 | |
} | |
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipPath) | |
shell: pwsh |