Skip to content

Commit

Permalink
CI-build the updater correctly this time.
Browse files Browse the repository at this point in the history
:)
  • Loading branch information
e3ndr committed Oct 29, 2024
1 parent 5d256b8 commit c7e4aaf
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 117 deletions.
108 changes: 80 additions & 28 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
Expand All @@ -15,40 +7,100 @@ on:
branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest
build_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: 📩 Set up JDK 11
uses: actions/checkout@v3

- name: 🏗️ Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "temurin"
java-version: 11
distribution: temurin
cache: maven

- name: Compile the updater.
- name: 🔨 Compile the updater
run: bash build.sh compile

- name: Build the Windows artifact.
- name: 📦 Build the Windows artifact
run: bash build.sh dist-windows
- name: Upload the Windows artifact.

- name: 🆙 Upload the Windows artifact (x86_64)
uses: actions/upload-artifact@v3
with:
name: Casterlabs-Caffeinated-Windows.zip
path: dist/artifacts/Windows.zip
name: Casterlabs-Caffeinated-windows-x86_64.zip
path: dist/artifacts/Casterlabs-Caffeinated-windows-x86_64.zip

- name: Create installer
uses: joncloud/[email protected]
with:
script-file: "Installer.nsi"

- name: Build the Linux artifact.
build_macos:
runs-on: ubuntu-latest
steps:
- name: 📩 Set up JDK 11
uses: actions/checkout@v3

- name: 🏗️ Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
cache: maven

- name: 🔨 Compile the updater
run: bash build.sh compile

- name: 📦 Build the macOS artifact
run: bash build.sh dist-macos

- name: 🆙 Upload the macOS artifact (aarch64)
uses: actions/upload-artifact@v3
with:
name: Casterlabs-Caffeinated-macos-aarch64.tar.gz
path: dist/artifacts/Casterlabs-Caffeinated-macos-aarch64.tar.gz

- name: 🆙 Upload the macOS artifact (x86_64)
uses: actions/upload-artifact@v3
with:
name: Casterlabs-Caffeinated-macos-x86_64.tar.gz
path: dist/artifacts/Casterlabs-Caffeinated-macos-x86_64.tar.gz

build_linux:
runs-on: ubuntu-latest
steps:
- name: 📩 Set up JDK 11
uses: actions/checkout@v3

- name: 🏗️ Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
cache: maven

- name: 🔨 Compile the updater
run: bash build.sh compile

- name: 📦 Build the Linux artifact
run: bash build.sh dist-linux
- name: Upload the Linux artifact.

- name: 🆙 Upload the Linux artifact (aarch64)
uses: actions/upload-artifact@v3
with:
name: Casterlabs-Caffeinated-Linux.tar.gz
path: dist/artifacts/Linux.tar.gz
name: Casterlabs-Caffeinated-gnulinux-aarch64.tar.gz
path: dist/artifacts/Casterlabs-Caffeinated-gnulinux-aarch64.tar.gz

- name: Build the macOS artifact.
run: bash build.sh dist-macos
- name: Upload the macOS artifact.
- name: 🆙 Upload the Linux artifact (arm)
uses: actions/upload-artifact@v3
with:
name: Casterlabs-Caffeinated-gnulinux-arm.tar.gz
path: dist/artifacts/Casterlabs-Caffeinated-gnulinux-arm.tar.gz

- name: 🆙 Upload the Linux artifact (x86_64)
uses: actions/upload-artifact@v3
with:
name: Casterlabs-Caffeinated-macOS.tar.gz
path: dist/artifacts/macOS.tar.gz
name: Casterlabs-Caffeinated-gnulinux-x86_64.tar.gz
path: dist/artifacts/Casterlabs-Caffeinated-gnulinux-x86_64.tar.gz
12 changes: 6 additions & 6 deletions Installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

;Name and file
!define COMPANY "Casterlabs"
!define NAME "Casterlabs Caffeinated"
!define NAME "Casterlabs-Caffeinated"
Name "${NAME}"
OutFile "dist/Casterlabs Caffeinated Setup.exe"
OutFile "dist/Casterlabs-Caffeinated-Setup.exe"
Unicode True

;Default installation folder
Expand Down Expand Up @@ -49,22 +49,22 @@ Var deleteUserData ; You could just store the HWND in $1 etc if you don't want t

Function .onInit
; Check to see if already installed (old installer).
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Casterlabs Caffeinated" "UninstallString"
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${NAME}" "UninstallString"
IfFileExists $R0 +1 +3
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Casterlabs Caffeinated" ; Forcibly remove the old version.
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${NAME}" ; Forcibly remove the old version.
RMDir /r "$INSTDIR"
FunctionEnd

Section "App"
SectionIn RO

SetOutPath "$INSTDIR"
File /r "dist\windows\*.*"
File /r "dist\build\windows-x86_64\*.*"

WriteUninstaller "$INSTDIR\Uninstall.exe"

WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${NAME}" \
"DisplayName" "Casterlabs Caffeinated"
"DisplayName" "${NAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${NAME}" \
"UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${NAME}" \
Expand Down
Binary file removed app_icon.icns
Binary file not shown.
131 changes: 48 additions & 83 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,97 +1,62 @@
#!/bin/bash

JRE_DOWNLOAD_URL__WINDOWS="https://api.adoptium.net/v3/binary/latest/11/ga/windows/x64/jre/hotspot/normal/eclipse?project=jdk"
JRE_DOWNLOAD_URL__LINUX="https://api.adoptium.net/v3/binary/latest/11/ga/linux/x64/jre/hotspot/normal/eclipse?project=jdk"
JRE_DOWNLOAD_URL__MACOS="https://api.adoptium.net/v3/binary/latest/11/ga/mac/x64/jre/hotspot/normal/eclipse?project=jdk"
set -e -o pipefail

APP_ID="co.casterlabs.caffeinated"
APP_NAME="Casterlabs-Caffeinated"
MAIN_CLASS="co.casterlabs.caffeinated.updater.Launcher"

# Compile everything
if [[ $@ == *"compile"* ]]; then
echo "------------ Compiling app ------------"
mvn clean package
echo "------------ Finishing compiling app ---------"
fi

# Reset the dist folder
rm -rf dist/*
mkdir -p dist
mkdir dist/artifacts

if [[ $@ == *"dist-windows"* ]]; then
echo "Building for Windows..."
mkdir dist/windows

if [ ! -f windows_runtime.zip ]; then
echo "Downloading JRE from ${JRE_DOWNLOAD_URL__WINDOWS}."
wget -O windows_runtime.zip $JRE_DOWNLOAD_URL__WINDOWS
fi

java -jar "packr.jar" \
--platform windows64 \
--jdk windows_runtime.zip \
--executable Casterlabs-Caffeinated-Updater \
--classpath target/Casterlabs-Caffeinated-Updater.jar \
--mainclass $MAIN_CLASS \
--vmargs caffeinated.channel=stable \
--output dist/windows

echo "Finished building for Windows."

cd dist/windows
zip -r ../artifacts/Windows.zip *
cd - # Return.
echo ""
fi
echo "------------ Bundling for Windows ------------"

if [[ $@ == *"dist-linux"* ]]; then
echo "Building for Linux..."
mkdir dist/linux

if [ ! -f linux_runtime.tar.gz ]; then
echo "Downloading JRE from ${JRE_DOWNLOAD_URL__LINUX}."
wget -O linux_runtime.tar.gz $JRE_DOWNLOAD_URL__LINUX
fi

java -jar "packr.jar" \
--platform linux64 \
--jdk linux_runtime.tar.gz \
--executable Casterlabs-Caffeinated-Updater \
--classpath target/Casterlabs-Caffeinated-Updater.jar \
--mainclass $MAIN_CLASS \
--vmargs caffeinated.channel=stable \
--output dist/linux

echo "Finished building for Linux."

cd dist/linux
tar -czvf ../artifacts/Linux.tar.gz *
cd - # Return.
echo ""
java -jar bundler.jar bundle \
--arch x86_64 --os windows \
--id $APP_ID --name $APP_NAME --icon icon.png \
--java 11 --dependency target/Casterlabs-Caffeinated-Updater.jar --main $MAIN_CLASS

echo "------------ Finished bundling for Windows ------------"
fi

if [[ $@ == *"dist-macos"* ]]; then
echo "Building for MacOS..."
mkdir dist/macos
mkdir dist/macos/Casterlabs-Caffeinated.app

if [ ! -f macos_runtime.tar.gz ]; then
echo "Downloading JRE from ${JRE_DOWNLOAD_URL__MACOS}."
wget -O macos_runtime.tar.gz $JRE_DOWNLOAD_URL__MACOS
fi

java -jar "packr.jar" \
--platform mac \
--jdk macos_runtime.tar.gz \
--executable Casterlabs-Caffeinated-Updater \
--icon app_icon.icns \
--bundle co.casterlabs.caffeinated \
--classpath target/Casterlabs-Caffeinated-Updater.jar \
--mainclass $MAIN_CLASS \
--vmargs caffeinated.channel=stable \
--output dist/macos/Casterlabs-Caffeinated.app

echo "Finished building for MacOS."

cd dist/macos
tar -czvf ../artifacts/macOS.tar.gz *
cd - # Return.
echo ""
echo "------------ Bundling for macOS ------------"

java -jar bundler.jar bundle \
--arch aarch64 --os macos \
--id $APP_ID --name $APP_NAME --icon icon.png \
--java 11 --dependency target/Casterlabs-Caffeinated-Updater.jar --main $MAIN_CLASS

java -jar bundler.jar bundle \
--arch x86_64 --os macos \
--id $APP_ID --name $APP_NAME --icon icon.png \
--java 11 --dependency target/Casterlabs-Caffeinated-Updater.jar --main $MAIN_CLASS

echo "------------ Finished bundling for macOS ------------"
fi

if [[ $@ == *"dist-linux"* ]]; then
echo "------------ Bundling for Linux ------------"

java -jar bundler.jar bundle \
--arch aarch64 --os gnulinux \
--id $APP_ID --name $APP_NAME --icon icon.png \
--java 11 --dependency target/Casterlabs-Caffeinated-Updater.jar --main $MAIN_CLASS

java -jar bundler.jar bundle \
--arch arm --os gnulinux \
--id $APP_ID --name $APP_NAME --icon icon.png \
--java 11 --dependency target/Casterlabs-Caffeinated-Updater.jar --main $MAIN_CLASS

java -jar bundler.jar bundle \
--arch x86_64 --os gnulinux \
--id $APP_ID --name $APP_NAME --icon icon.png \
--java 11 --dependency target/Casterlabs-Caffeinated-Updater.jar --main $MAIN_CLASS

echo "------------ Finished bundling for Linux ------------"
fi

Binary file added bundler.jar
Binary file not shown.
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed packr.jar
Binary file not shown.

0 comments on commit c7e4aaf

Please sign in to comment.