Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/VersionTools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
interface Config {
meta: {
version: string,
}
}

const filePath = "./mod.json";
const modConfig: Config = JSON.parse(await Deno.readTextFile(filePath));

function bumpVersion(version: string) {
const parts = version.split(".").map(Number);
parts[2]++;
return parts.join(".");
}

modConfig.meta.version = bumpVersion(modConfig.meta.version);
Deno.writeTextFile(filePath, JSON.stringify(modConfig, null, 4));

// Output the new version for GitHub Actions
console.log(modConfig.meta.version);
209 changes: 105 additions & 104 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,111 +1,112 @@
name: Publish Version

on:
workflow_dispatch:
workflow_dispatch:

env:
MOD_NAME: Better-Inventory
MOD_NAME: Better-Inventory # Replace with your mod name

jobs:
build:
runs-on: windows-latest

steps:
# Clone the current repository
- name: Checkout code
uses: actions/checkout@v2

# Clone AmethystAPI into /amethyst
- name: Checkout Amethyst
uses: actions/checkout@v2
with:
repository: 'FrederoxDev/Amethyst'
path: 'amethyst'

# Install required tools
- name: Install NASM and GH
run: |
choco install nasm -y
choco install gh -y
shell: cmd

- name: Setup Visual studio
uses: microsoft/setup-msbuild@v2

# Bump up the version number
- name: Extract and increment version number
id: increment_version
run: |
$filePath = "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 Mod
run: |
mkdir build
cd build
cmake -DCI_CD_BUILD=ON ..
msbuild ${{ env.MOD_NAME }}.sln

- name: Package Build
run: |
$version = $env:NEW_VERSION
$sourcePath = "dist/${{ env.MOD_NAME }}@$version"
$zipPath = "dist/${{ env.MOD_NAME }}@$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

- name: Create GitHub Release
id: create_release
run: |
$tag_name = "v$env:NEW_VERSION"
$release_name = "Release $env:NEW_VERSION"
gh release create $tag_name --title "$release_name" --notes "Automated release" --target main --repo ${{ github.repository }} --draft=false --prerelease=false
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset
run: |
$asset_path = "dist/${{ env.MOD_NAME }}@$env:NEW_VERSION.zip"
$asset_label = "${{ env.MOD_NAME }}@$env:NEW_VERSION.zip"
gh release upload "v$env:NEW_VERSION" "$asset_path#$asset_label" --repo ${{ github.repository }}
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: windows-latest
steps:
# Checkout current mod
- name: Checkout code
uses: actions/checkout@v4

# Checkout AmethystAPI into /Amethyst
- name: Clone AmethystAPI manually
run: git clone --recurse-submodules https://github.com/FrederoxDev/Amethyst.git Amethyst

# Build dependencies
- name: Install Build Tools
shell: powershell
run: |
choco install xmake -y
choco install deno -y

# Bump mod version
- name: Get mod version
id: get_version
shell: powershell
run: |
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv
$NEW_VERSION = deno run --allow-read --allow-write .github/workflows/VersionTools.ts
echo "NEW_VERSION=$NEW_VERSION" >> $env:GITHUB_ENV

- name: Push bumped version
shell: powershell
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add mod.json
git commit -m "Bump version to $env:NEW_VERSION"
git push

- name: Package Resources
shell: powershell
run: |
$url = "https://github.com/Bedrock-OSS/regolith/releases/download/1.5.2/regolith_1.5.2_windows_386.zip"
$zipPath = "$env:TEMP\regolith.zip"
$extractPath = "$env:TEMP\regolith"

Invoke-WebRequest $url -OutFile $zipPath
Expand-Archive $zipPath -DestinationPath $extractPath

cd data

# Ensure deno is in path
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv

& "$extractPath\regolith.exe" install-all
& "$extractPath\regolith.exe" run local

- name: Build
run: |
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv

xmake f -y --automated_build=y
xmake
shell: powershell

- name: Package Mod
shell: powershell
run: |
$zipName = "$env:MOD_NAME@$env:NEW_VERSION.zip"
$distPath = "dist"

$excluded = Get-ChildItem -Path $distPath -Recurse -File | Where-Object { $_.Extension -in ".lib", ".exp" }
$tempPath = "$env:TEMP\dist_temp"
Remove-Item $tempPath -Recurse -Force -ErrorAction SilentlyContinue
Copy-Item $distPath $tempPath -Recurse

foreach ($file in $excluded) {
$fileToRemove = $file.FullName.Replace((Resolve-Path $distPath).Path, $tempPath)
Remove-Item $fileToRemove -Force
}

Compress-Archive -Path "$tempPath\*" -DestinationPath $zipName

- name: Create GitHub Release
id: create_release
run: |
$tag_name = "v$env:NEW_VERSION"
$release_name = "Release $env:NEW_VERSION"
gh release create $tag_name --title "$release_name" --notes "Automated release" --target main --repo ${{ github.repository }} --draft=false --prerelease=false
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Release Asset
run: |
$asset_path = "${{ env.MOD_NAME }}@$env:NEW_VERSION.zip"
$asset_label = "${{ env.MOD_NAME }}@$env:NEW_VERSION.zip"
gh release upload "v$env:NEW_VERSION" "$asset_path#$asset_label" --repo ${{ github.repository }}
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
build/
/build
/.xmake
/.vscode/compile_commands.json
/.importer
/vsxmake2022
/Amethyst
/dist

!data/packs/RP/textures/blocks
!data/packs/RP/textures/items
!data/packs/RP/textures/entity
!data/packs/BP
23 changes: 23 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"${AMETHYST_SRC}/AmethystAPI/src",
"${AMETHYST_SRC}/AmethystAPI/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.26100.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++23",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

59 changes: 0 additions & 59 deletions CMakeLists.txt

This file was deleted.

Loading