Skip to content

Commit 58add4e

Browse files
committed
Updated to newer Amethyst format
1 parent a197b56 commit 58add4e

30 files changed

Lines changed: 704 additions & 604 deletions

.github/workflows/VersionTools.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
interface Config {
2+
meta: {
3+
version: string,
4+
}
5+
}
6+
7+
const filePath = "./mod.json";
8+
const modConfig: Config = JSON.parse(await Deno.readTextFile(filePath));
9+
10+
function bumpVersion(version: string) {
11+
const parts = version.split(".").map(Number);
12+
parts[2]++;
13+
return parts.join(".");
14+
}
15+
16+
modConfig.meta.version = bumpVersion(modConfig.meta.version);
17+
Deno.writeTextFile(filePath, JSON.stringify(modConfig, null, 4));
18+
19+
// Output the new version for GitHub Actions
20+
console.log(modConfig.meta.version);

.github/workflows/build.yml

Lines changed: 105 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,112 @@
11
name: Publish Version
22

33
on:
4-
workflow_dispatch:
4+
workflow_dispatch:
55

66
env:
7-
MOD_NAME: Better-Inventory
7+
MOD_NAME: Better-Inventory # Replace with your mod name
88

99
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 }}
10+
build:
11+
runs-on: windows-latest
12+
steps:
13+
# Checkout current mod
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
# Checkout AmethystAPI into /Amethyst
18+
- name: Clone AmethystAPI manually
19+
run: git clone --recurse-submodules https://github.com/FrederoxDev/Amethyst.git Amethyst
20+
21+
# Build dependencies
22+
- name: Install Build Tools
23+
shell: powershell
24+
run: |
25+
choco install xmake -y
26+
choco install deno -y
27+
28+
# Bump mod version
29+
- name: Get mod version
30+
id: get_version
31+
shell: powershell
32+
run: |
33+
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
34+
refreshenv
35+
$NEW_VERSION = deno run --allow-read --allow-write .github/workflows/VersionTools.ts
36+
echo "NEW_VERSION=$NEW_VERSION" >> $env:GITHUB_ENV
37+
38+
- name: Push bumped version
39+
shell: powershell
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: |
43+
git config user.name "github-actions[bot]"
44+
git config user.email "github-actions[bot]@users.noreply.github.com"
45+
git add mod.json
46+
git commit -m "Bump version to $env:NEW_VERSION"
47+
git push
48+
49+
- name: Package Resources
50+
shell: powershell
51+
run: |
52+
$url = "https://github.com/Bedrock-OSS/regolith/releases/download/1.5.2/regolith_1.5.2_windows_386.zip"
53+
$zipPath = "$env:TEMP\regolith.zip"
54+
$extractPath = "$env:TEMP\regolith"
55+
56+
Invoke-WebRequest $url -OutFile $zipPath
57+
Expand-Archive $zipPath -DestinationPath $extractPath
58+
59+
cd data
60+
61+
# Ensure deno is in path
62+
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
63+
refreshenv
64+
65+
& "$extractPath\regolith.exe" install-all
66+
& "$extractPath\regolith.exe" run local
67+
68+
- name: Build
69+
run: |
70+
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
71+
refreshenv
72+
73+
xmake f -y --automated_build=y
74+
xmake
75+
shell: powershell
76+
77+
- name: Package Mod
78+
shell: powershell
79+
run: |
80+
$zipName = "$env:MOD_NAME@$env:NEW_VERSION.zip"
81+
$distPath = "dist"
82+
83+
$excluded = Get-ChildItem -Path $distPath -Recurse -File | Where-Object { $_.Extension -in ".lib", ".exp" }
84+
$tempPath = "$env:TEMP\dist_temp"
85+
Remove-Item $tempPath -Recurse -Force -ErrorAction SilentlyContinue
86+
Copy-Item $distPath $tempPath -Recurse
87+
88+
foreach ($file in $excluded) {
89+
$fileToRemove = $file.FullName.Replace((Resolve-Path $distPath).Path, $tempPath)
90+
Remove-Item $fileToRemove -Force
91+
}
92+
93+
Compress-Archive -Path "$tempPath\*" -DestinationPath $zipName
94+
95+
- name: Create GitHub Release
96+
id: create_release
97+
run: |
98+
$tag_name = "v$env:NEW_VERSION"
99+
$release_name = "Release $env:NEW_VERSION"
100+
gh release create $tag_name --title "$release_name" --notes "Automated release" --target main --repo ${{ github.repository }} --draft=false --prerelease=false
101+
shell: pwsh
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
105+
- name: Upload Release Asset
106+
run: |
107+
$asset_path = "${{ env.MOD_NAME }}@$env:NEW_VERSION.zip"
108+
$asset_label = "${{ env.MOD_NAME }}@$env:NEW_VERSION.zip"
109+
gh release upload "v$env:NEW_VERSION" "$asset_path#$asset_label" --repo ${{ github.repository }}
110+
shell: pwsh
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
build/
1+
/build
2+
/.xmake
3+
/.vscode/compile_commands.json
4+
/.importer
5+
/vsxmake2022
6+
/Amethyst
7+
/dist
8+
9+
!data/packs/RP/textures/blocks
10+
!data/packs/RP/textures/items
11+
!data/packs/RP/textures/entity
12+
!data/packs/BP

.vscode/c_cpp_properties.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Win32",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"${AMETHYST_SRC}/AmethystAPI/src",
8+
"${AMETHYST_SRC}/AmethystAPI/include"
9+
],
10+
"defines": [
11+
"_DEBUG",
12+
"UNICODE",
13+
"_UNICODE"
14+
],
15+
"windowsSdkVersion": "10.0.26100.0",
16+
"compilerPath": "cl.exe",
17+
"cStandard": "c17",
18+
"cppStandard": "c++23",
19+
"intelliSenseMode": "windows-msvc-x64"
20+
}
21+
],
22+
"version": 4
23+
}

.vscode/settings.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)