1+ name : Publish Version
2+
3+ on :
4+ workflow_dispatch :
5+
6+ env :
7+ MOD_NAME : BetterInventory
8+
9+ jobs :
10+ build :
11+ runs-on : windows-latest
12+
13+ steps :
14+ # Clone the current repository
15+ - name : Checkout code
16+ uses : actions/checkout@v2
17+
18+ # Clone AmethystAPI into /amethyst
19+ - name : Checkout Amethyst
20+ uses : actions/checkout@v2
21+ with :
22+ repository : ' FrederoxDev/Amethyst'
23+ path : ' amethyst'
24+
25+ # Install required tools
26+ - name : Install NASM and GH
27+ run : |
28+ choco install nasm -y
29+ choco install gh -y
30+ shell : cmd
31+
32+ - name : Setup Visual studio
33+ uses : microsoft/setup-msbuild@v2
34+
35+ # Bump up the version number
36+ - name : Extract and increment version number
37+ id : increment_version
38+ run : |
39+ $filePath = "CMakeLists.txt"
40+ $version_line = Select-String -Path $filePath -Pattern 'set\(MOD_VERSION "(.*)"\)'
41+ if ($version_line -match 'set\(MOD_VERSION "(\d+)\.(\d+)\.(\d+)"\)') {
42+ $major = [int]$matches[1]
43+ $minor = [int]$matches[2]
44+ $patch = [int]$matches[3]
45+
46+ # Increment the minor version
47+ $new_patch = $patch + 1
48+ $new_version = "$major.$minor.$new_patch"
49+
50+ # Update the CMakeLists.txt file
51+ (Get-Content $filePath) -replace 'set\(MOD_VERSION ".*"\)', "set(MOD_VERSION `"$new_version`")" | Set-Content $filePath
52+
53+ echo "NEW_VERSION=$new_version" >> $env:GITHUB_ENV
54+ echo "FILE_PATH=$filePath" >> $env:GITHUB_ENV
55+ } else {
56+ Write-Error "Version line not found or does not match the expected format."
57+ exit 1
58+ }
59+ shell : pwsh
60+
61+ - name : Push bumped version
62+ run : |
63+ git config user.name "github-actions[bot]"
64+ git config user.email "github-actions[bot]@users.noreply.github.com"
65+ git add $env:FILE_PATH
66+ git commit -m "Bump version to $env:NEW_VERSION"
67+ git push
68+ env :
69+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
70+ shell : pwsh
71+
72+ - name : Build Mod
73+ run : |
74+ mkdir build
75+ cd build
76+ cmake -DCI_CD_BUILD=ON ..
77+ msbuild ${{ env.MOD_NAME }}.sln
78+
79+ - name : Package Build
80+ run : |
81+ $version = $env:NEW_VERSION
82+ $sourcePath = "dist/${{ env.MOD_NAME }}@$version"
83+ $zipPath = "dist/${{ env.MOD_NAME }}@$version.zip"
84+
85+ if (-Not (Test-Path -Path $sourcePath)) {
86+ Write-Error "Source path does not exist: $sourcePath"
87+ exit 1
88+ }
89+
90+ Add-Type -AssemblyName System.IO.Compression.FileSystem
91+ [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcePath, $zipPath)
92+ shell : pwsh
93+
94+ - name : Create GitHub Release
95+ id : create_release
96+ run : |
97+ $tag_name = "v$env:NEW_VERSION"
98+ $release_name = "Release $env:NEW_VERSION"
99+ gh release create $tag_name --title "$release_name" --notes "Automated release" --target main --repo ${{ github.repository }} --draft=false --prerelease=false
100+ shell : pwsh
101+ env :
102+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
103+
104+ - name : Upload Release Asset
105+ run : |
106+ $asset_path = "dist/${{ env.MOD_NAME }}@$env:NEW_VERSION.zip"
107+ $asset_label = "${{ env.MOD_NAME }}@$env:NEW_VERSION.zip"
108+ gh release upload "v$env:NEW_VERSION" "$asset_path#$asset_label" --repo ${{ github.repository }}
109+ shell : pwsh
110+ env :
111+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments