Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
[skip ci] update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
404Setup committed Sep 1, 2024
1 parent c1e61bb commit a0a0964
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
1 change: 0 additions & 1 deletion .github/workflows/v121_1_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ jobs:
${{ env.commit_msg }}
artifacts: |
${{ env.jar_dir }}
${{ env.jar_dir_bundler }}
generateReleaseNotes: true
prerelease: ${{ env.pre }}
makeLatest: ${{ env.make_latest }}
Expand Down
10 changes: 5 additions & 5 deletions scripts/SetEnv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ $commitid = git log --pretty='%h' -1
$mcversion = Get-Property "mcVersion"
$grdversion = Get-Property "version"
$preVersion = Get-Property "preVersion"
$release_tag = "$mcversion-$commitid"
$release_tag = "$mcversion-$commitid-september-test"
$jarName = "$project_id-paperclip-$mcversion.jar"
$jarName_bundler = "$project_id-bundler-$mcversion.jar"
#$jarName_bundler = "$project_id-bundler-$mcversion.jar"
$jarName_dir = "build/libs/$jarName"
$jarName_bundler_dir = "build/libs/$jarName_bundler"
#$jarName_bundler_dir = "build/libs/$jarName_bundler"
$make_latest = if ($preVersion -eq "true") { "false" } else { "true" }

Move-Item "build/libs/$project_id-paperclip-$grdversion-mojmap.jar" $jarName_dir
Move-Item "build/libs/$project_id-bundler-$grdversion-mojmap.jar" $jarName_bundler_dir
#Move-Item "build/libs/$project_id-bundler-$grdversion-mojmap.jar" $jarName_bundler_dir

Add-Content -Path $env:GITHUB_ENV -Value "project_id=$project_id"
Add-Content -Path $env:GITHUB_ENV -Value "project_id_b=$project_id_b"
Expand All @@ -40,5 +40,5 @@ Add-Content -Path $env:GITHUB_ENV -Value "pre=$preVersion"
Add-Content -Path $env:GITHUB_ENV -Value "tag=$release_tag"
Add-Content -Path $env:GITHUB_ENV -Value "jar=$jarName"
Add-Content -Path $env:GITHUB_ENV -Value "jar_dir=$jarName_dir"
Add-Content -Path $env:GITHUB_ENV -Value "jar_dir_bundler=$jarName_bundler_dir"
#Add-Content -Path $env:GITHUB_ENV -Value "jar_dir_bundler=$jarName_bundler_dir"
Add-Content -Path $env:GITHUB_ENV -Value "make_latest=$make_latest"
22 changes: 22 additions & 0 deletions scripts/clear_build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$currentDirectory = Get-Location

if (Test-Path "$currentDirectory\.git") {
$gitRepoName = (git rev-parse --show-toplevel | Split-Path -Leaf).ToLower()

$jarDirectory = Join-Path -Path $currentDirectory -ChildPath "build/libs"

if (Test-Path $jarDirectory) {
$regexPattern = "$gitRepoName-bundler-(\d+\.\d+\.\d+)(-[^\-]+)*\.jar"

Get-ChildItem -Path $jarDirectory -Filter "*.jar" | Where-Object { $_.Name -match $regexPattern } | ForEach-Object {
Write-Host "Deleting file: $($_.FullName)"
Remove-Item -Path $_.FullName -Force
}
} else {
Write-Error "Directory 'build/libs' does not exist."
exit 1
}
} else {
Write-Error "Current directory is not a Git repository."
exit 1
}
21 changes: 15 additions & 6 deletions scripts/create_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ param(
[string]$channel = "default"
)

$currentDirectory = Get-Location

if (-not (Test-Path "$currentDirectory\.git")) {
Write-Error "Current directory is not a Git repository."
exit 1
}

$repoNameClassic = git rev-parse --show-toplevel | Split-Path -Leaf
$repoName = $repoNameClassic.ToLower()

$api = "https://mars.tranic.one"

if (-not $token)
Expand All @@ -25,8 +35,7 @@ function Get-GitInfo
{
$commit = git log -1 --pretty=format:"%H"
$title = git log -1 --pretty=format:"%s"
$message = git log -1 --pretty=format:"%b"
$repoName = (git rev-parse --show-toplevel | Split-Path -Leaf).ToLower()
$message = (git log -1 --pretty=format:"%B") -replace "`r`n", "\n" -replace "`n", "\n"

return @{
Commit = $commit
Expand All @@ -52,7 +61,7 @@ function Get-BuildInfo
$fileInfo = @{ }
foreach ($file in $files)
{
if ($file.Name -match "levelbukkit-(bundler|paperclip)-(\d+\.\d+(\.\d+)?)(-[^\-]+)*\.jar")
if ($file.Name -match "$repoName-(bundler|paperclip)-(\d+\.\d+\.\d+)(-[^\-]+)*\.jar")
{
$key = $matches[1]
$version = $matches[2]
Expand All @@ -61,7 +70,7 @@ function Get-BuildInfo
$fileInfo[$key] = @{
name = $file.Name
sha256 = $fileHash.Hash
url = "https://github.com/LevelTranic/$( $gitInfo.RepoName )/releases/download/$mcVersion-$commitHash/$( $file.Name )"
url = "https://github.com/LevelTranic/$( $repoNameClassic )/releases/download/$mcVersion-$commitHash/$( $file.Name )"
}
}
}
Expand Down Expand Up @@ -117,7 +126,7 @@ $gitInfo = Get-GitInfo
$buildInfo = Get-BuildInfo

$jsonData = @{
project = $gitInfo.RepoName
project = $repoName
version = $buildInfo.Version
family = $buildInfo.Family
channel = $channel
Expand Down Expand Up @@ -151,7 +160,7 @@ if ($responseObj -and $responseObj.build_id -ne 0)
try
{
$uploadData = @{
project = $gitInfo.RepoName
project = $repoName
version = $buildInfo.Version
build = $responseObj.build_id
file = $buildInfo.Files
Expand Down

0 comments on commit a0a0964

Please sign in to comment.