Skip to content

Commit

Permalink
Add standalone jar build
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiinaSekiu committed Sep 11, 2024
1 parent 7e1a4a8 commit c0d31b5
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 35 deletions.
34 changes: 33 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,42 @@ jobs:
name: MiniLPA-${{ env.SHORT_COMMIT_ID }}-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.type }}${{ matrix.wayland && '-Wayland' || '' }}
path: |
build/dist/
build-standalone-jar:
name: Standalone Jar
runs-on: ubuntu-latest
steps:
- name: Checkout MiniLPA
uses: actions/checkout@v4

- name: Setup Java JDK
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Build Standalone Jar
shell: pwsh
run: |
./scripts/Build.ps1
- name: Get Short Commit Id
shell: pwsh
run: |
"SHORT_COMMIT_ID=$($Env:GITHUB_SHA.Substring(0, 7))" | Out-File -FilePath $Env:GITHUB_ENV -Append
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: MiniLPA-${{ env.SHORT_COMMIT_ID }}-standalone-jar
path: |
build/libs/MiniLPA-all.jar
canary-telegram:
name: Canary(Telegram)
runs-on: macos-latest
needs: [ build-with-zulu, build-with-jbr ]
needs: [ build-with-zulu, build-with-jbr, build-standalone-jar ]
if: "!startsWith(github.ref, 'refs/tags/v')"
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
Expand Down
71 changes: 37 additions & 34 deletions scripts/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,47 +66,50 @@ Pop-Location

if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

$DistFolderPath = "$ProjectRootPath/build/dist/"
if ($NativeExecutable)
{
$DistFolderPath = "$ProjectRootPath/build/dist/"

$OS = if ($IsWindows) { 'Windows' }
elseif ($IsLinux) { 'Linux' }
elseif ($IsMacOS) { 'macOS' }
else { throw 'unknown os' }
$OS = if ($IsWindows) { 'Windows' }
elseif ($IsLinux) { 'Linux' }
elseif ($IsMacOS) { 'macOS' }
else { throw 'unknown os' }

$OSArchitecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
$Arch = if ($OSArchitecture -eq 'X64') { 'x86_64' }
elseif ($OSArchitecture -eq 'Arm64') { 'aarch64' }
else { throw 'unkown arch' }
$OSArchitecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
$Arch = if ($OSArchitecture -eq 'X64') { 'x86_64' }
elseif ($OSArchitecture -eq 'Arm64') { 'aarch64' }
else { throw 'unkown arch' }

$Name = "MiniLPA-$OS-$Arch"
$Name = "MiniLPA-$OS-$Arch"

if ($NativeWayland)
{
$Name += '-Wayland'
}
if ($NativeWayland)
{
$Name += '-Wayland'
}

if ($NativeExecutableType -eq 'app-image')
{
$AppImageFolderPath = "$DistFolderPath/MiniLPA*"
Compress-Archive -Path "$AppImageFolderPath/*" -DestinationPath "$DistFolderPath/$Name.zip" -Force
Get-ChildItem -Path $DistFolderPath -Directory | Where-Object { $_.Name -like 'MiniLPA*' } | Remove-Item -Recurse -Force
}
else
{
Get-ChildItem -Path $DistFolderPath -File -Filter "MiniLPA*$NativeExecutableType" | ForEach-Object {
$DistPath = "$DistFolderPath$Name$( $_.Extension )"
Move-Item -Path $_.FullName -Destination $DistPath -Force
if ($NativeExecutableType -eq "msi")
{
if ($IsDirty) { $Guid = [System.Guid]::NewGuid() }
else
if ($NativeExecutableType -eq 'app-image')
{
$AppImageFolderPath = "$DistFolderPath/MiniLPA*"
Compress-Archive -Path "$AppImageFolderPath/*" -DestinationPath "$DistFolderPath/$Name.zip" -Force
Get-ChildItem -Path $DistFolderPath -Directory | Where-Object { $_.Name -like 'MiniLPA*' } | Remove-Item -Recurse -Force
}
else
{
Get-ChildItem -Path $DistFolderPath -File -Filter "MiniLPA*$NativeExecutableType" | ForEach-Object {
$DistPath = "$DistFolderPath$Name$( $_.Extension )"
Move-Item -Path $_.FullName -Destination $DistPath -Force
if ($NativeExecutableType -eq "msi")
{
$CommitId = git rev-parse HEAD
$CommitIdBytes = [System.Text.Encoding]::UTF8.GetBytes($CommitId)
$GuidBytes = $CommitIdBytes[0..15] -as [Byte[]]
$Guid = [System.Guid]::new($guidBytes)
if ($IsDirty) { $Guid = [System.Guid]::NewGuid() }
else
{
$CommitId = git rev-parse HEAD
$CommitIdBytes = [System.Text.Encoding]::UTF8.GetBytes($CommitId)
$GuidBytes = $CommitIdBytes[0..15] -as [Byte[]]
$Guid = [System.Guid]::new($guidBytes)
}
& "$PSScriptRoot/Update-MSI-ProductCode.ps1" -Path $DistPath -ProductCode "{$($Guid.Guid)}"
}
& "$PSScriptRoot/Update-MSI-ProductCode.ps1" -Path $DistPath -ProductCode "{$($Guid.Guid)}"
}
}
}

0 comments on commit c0d31b5

Please sign in to comment.