feat(CI): Added scanning of dev docker images and M1 macos build support #1313
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Package Drifty | |
on: | |
push: | |
paths-ignore: | |
- "Website/**" | |
- "*.md" | |
- "*.txt" | |
pull_request: | |
paths-ignore: | |
- "Website/**" | |
- "*.md" | |
- "*.txt" | |
workflow_dispatch: | |
inputs: | |
create_release: | |
description: 'True to create release, else false' | |
required: true | |
type: boolean | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-Drifty: | |
name: Build [${{ matrix.os }}, ${{ matrix.mode }}] | |
strategy: | |
matrix: | |
os: ["windows-latest", "macos-latest", "ubuntu-latest", "macos-14"] # macos-14 has arm64 architecture, others have amd64 | |
mode: ["CLI", "GUI"] | |
fail-fast: false | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Update system packages | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.mode == 'GUI' }} | |
run: sudo apt-get update | |
- name: Install required build dependencies for Linux | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.mode == 'GUI' }} | |
run: | | |
sudo apt-get install libasound2-dev libavcodec-dev libavformat-dev libavutil-dev libfreetype6-dev | |
sudo apt-get install libgl-dev libglib2.0-dev libgtk-3-dev libpango1.0-dev libx11-dev libxtst-dev zlib1g-dev | |
- name: Set up GraalVM JDK 21 | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '21' | |
distribution: 'graalvm' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
set-java-home: true | |
cache: 'maven' | |
- name: Package Drifty CLI for ${{ matrix.os }} with GraalVM | |
if: ${{ matrix.mode == 'CLI' }} | |
shell: bash | |
run: | | |
if ${{ matrix.os == 'macos-latest' || matrix.os == 'macos-14' }}; then | |
mvn -P build-drifty-cli-for-macos-latest package -rf :CLI | |
else | |
mvn -P build-drifty-cli-for-${{ matrix.os }} package -rf :CLI | |
fi | |
- name: Set Up Maven version 3.8.8 # For GUI build issues, maven version 3.8.8 needs to be used | |
if: ${{ matrix.mode == 'GUI' }} | |
uses: stCarolas/setup-maven@v5 | |
with: | |
maven-version: 3.8.8 | |
- name: Build platform-specific C object for missing jdk libraries | |
if: ${{ matrix.mode == 'GUI' }} | |
shell: bash | |
run: | | |
if ${{ matrix.os == 'macos-latest' || matrix.os == 'macos-14' }}; then | |
gcc -c config/missing_symbols.c -o config/missing_symbols-macos-latest.o | |
else | |
gcc -c config/missing_symbols.c -o config/missing_symbols-${{ matrix.os }}.o | |
fi | |
- name: Install dependency modules for GUI | |
if: ${{ matrix.mode == 'GUI' }} | |
run: mvn -U clean install | |
- name: Package Drifty GUI for ${{ matrix.os }} with GluonFX maven plugin | |
if: ${{ matrix.mode == 'GUI' }} | |
run: | | |
if ${{ matrix.os == 'macos-latest' || matrix.os == 'macos-14' }}; then | |
mvn -P build-drifty-gui-for-macos-latest gluonfx:build gluonfx:package -rf :GUI | |
else | |
mvn -P build-drifty-gui-for-${{ matrix.os }} gluonfx:build gluonfx:package -rf :GUI | |
fi | |
- name: Create Application Type specific folders | |
run: | | |
mkdir build | |
mkdir build/${{ matrix.mode }} | |
- name: Categorise build artifacts for linux | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
if ${{ matrix.mode == 'CLI' }}; then | |
mv "CLI/target/CLI/linux/Drifty CLI" "CLI/target/CLI/linux/Drifty-CLI_linux" | |
mv "CLI/target/CLI/linux/Drifty-CLI_linux" -t build/CLI | |
else | |
mv GUI/target/gluonfx/x86_64-linux/GUI "GUI/target/gluonfx/x86_64-linux/Drifty-GUI_linux" | |
mv "GUI/target/gluonfx/x86_64-linux/Drifty-GUI_linux" -t build/GUI | |
fi | |
- name: Categorise build artifacts for windows | |
if: ${{ matrix.os == 'windows-latest' }} | |
shell: bash | |
run: | | |
if ${{ matrix.mode == 'CLI' }}; then | |
mv "CLI/target/CLI/windows/Drifty CLI.exe" "CLI/target/CLI/windows/Drifty-CLI.exe" | |
mv "CLI/target/CLI/windows/Drifty-CLI.exe" build/CLI | |
else | |
mv GUI/target/gluonfx/x86_64-windows/GUI-1.0.msi "GUI/target/gluonfx/x86_64-windows/Drifty-GUI.msi" | |
mv GUI/target/gluonfx/x86_64-windows/GUI.exe "GUI/target/gluonfx/x86_64-windows/Drifty-GUI.exe" | |
mv "GUI/target/gluonfx/x86_64-windows/Drifty-GUI.msi" build/GUI | |
mv "GUI/target/gluonfx/x86_64-windows/Drifty-GUI.exe" build/GUI | |
fi | |
- name: Categorise build artifacts for macOS | |
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'macos-14' }} | |
run: | | |
if ${{ matrix.mode == 'CLI' }}; then | |
mv "CLI/target/CLI/macos/Drifty CLI" "CLI/target/CLI/macos/Drifty-CLI_macos" | |
mv "CLI/target/CLI/macos/Drifty-CLI_macos" build/CLI | |
else | |
mv GUI/target/gluonfx/x86_64-darwin/GUI-1.0.0.pkg "GUI/target/gluonfx/x86_64-darwin/Drifty-GUI.pkg" | |
mv GUI/target/gluonfx/x86_64-darwin/GUI.app "GUI/target/gluonfx/x86_64-darwin/Drifty-GUI.app" | |
mv "GUI/target/gluonfx/x86_64-darwin/Drifty-GUI.pkg" build/GUI | |
mv "GUI/target/gluonfx/x86_64-darwin/Drifty-GUI.app" build/GUI | |
fi | |
- name: Tar build files # To prevent file permission loss | |
run: | | |
tar -cvf ${{ matrix.os }}-${{ matrix.mode }}.tar build/${{ matrix.mode }} | |
- name: Push generated artifacts for ${{ matrix.os }} for ${{ matrix.mode }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-${{ matrix.mode }}-Build-Files | |
path: ${{ matrix.os }}-${{ matrix.mode }}.tar | |
generate-metadata-and-create-release: | |
name: Artifacts Metadata & Release | |
runs-on: ubuntu-latest | |
needs: build-Drifty | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Drifty version from version.json file | |
run: echo "VERSION=$(jq .version version.json | sed -r 's/"//g')" >> $GITHUB_ENV | |
- name: Set Drifty version in pom.xml | |
run: mvn versions:set -D newVersion=$VERSION -D generateBackupPoms=false | |
- name: Download Build artifacts | |
uses: actions/download-artifact@v4 | |
- name: Make OS specific build directories | |
run: | | |
mkdir linux | |
mkdir macos | |
mkdir windows | |
- name: Extract build files from tar | |
run: | | |
tar -xvf ubuntu-latest-CLI-Build-Files/ubuntu-latest-CLI.tar -C linux | |
tar -xvf ubuntu-latest-GUI-Build-Files/ubuntu-latest-GUI.tar -C linux | |
tar -xvf macos-latest-CLI-Build-Files/macos-latest-CLI.tar -C macos | |
tar -xvf macos-latest-GUI-Build-Files/macos-latest-GUI.tar -C macos | |
tar -xvf windows-latest-CLI-Build-Files/windows-latest-CLI.tar -C windows | |
tar -xvf windows-latest-GUI-Build-Files/windows-latest-GUI.tar -C windows | |
- name: Get Size of Build Artifacts | |
run: | | |
echo "CLI_LINUX_SIZE=$(echo `du -h 'linux/build/CLI/Drifty-CLI_linux'` | sed 's/ .*//')" >> "$GITHUB_ENV" | |
echo "GUI_LINUX_SIZE=$(echo `du -h 'linux/build/GUI/Drifty-GUI_linux'` | sed 's/ .*//')" >> "$GITHUB_ENV" | |
echo "CLI_MACOS_SIZE=$(echo `du -h 'macos/build/CLI/Drifty-CLI_macos'` | sed 's/ .*//')" >> "$GITHUB_ENV" | |
echo "GUI_MACOS_PKG_SIZE=$(echo `du -h 'macos/build/GUI/Drifty-GUI.pkg'` | sed 's/ .*//')" >> "$GITHUB_ENV" | |
echo "GUI_MACOS_APP_SIZE=$(echo `du -h 'macos/build/GUI/Drifty-GUI.app'` | sed 's/ .*//')" >> "$GITHUB_ENV" | |
echo "CLI_WINDOWS_SIZE=$(echo `du -h 'windows/build/CLI/Drifty-CLI.exe'` | sed 's/ .*//')" >> "$GITHUB_ENV" | |
echo "GUI_WINDOWS_MSI_SIZE=$(echo `du -h 'windows/build/GUI/Drifty-GUI.msi'` | sed 's/ .*//')" >> "$GITHUB_ENV" | |
echo "GUI_WINDOWS_EXE_SIZE=$(echo `du -h 'windows/build/GUI/Drifty-GUI.exe'` | sed 's/ .*//')" >> "$GITHUB_ENV" | |
- name: Generate Artifact metadata summary | |
run: | | |
echo "# Drifty v$VERSION Built! :rocket:" >> $GITHUB_STEP_SUMMARY | |
echo "## Build Artifacts :package: Summary :memo:" >> $GITHUB_STEP_SUMMARY | |
echo "### Artifacts :package: Generated for Linux :penguin:" >> $GITHUB_STEP_SUMMARY | |
echo "| Application Type | Artifact Name | Size |" >> $GITHUB_STEP_SUMMARY | |
echo "|------------------|---------------|------|" >> $GITHUB_STEP_SUMMARY | |
echo "| CLI | Drifty-CLI_linux | $CLI_LINUX_SIZE |" >> $GITHUB_STEP_SUMMARY | |
echo "| GUI | Drifty-GUI_linux | $GUI_LINUX_SIZE |" >> $GITHUB_STEP_SUMMARY | |
echo "### Artifacts :package: Generated for macOS :apple:" >> $GITHUB_STEP_SUMMARY | |
echo "| Application Type | Artifact Name | Size |" >> $GITHUB_STEP_SUMMARY | |
echo "|------------------|---------------|------|" >> $GITHUB_STEP_SUMMARY | |
echo "| CLI | Drifty-CLI_macos | $CLI_MACOS_SIZE |" >> $GITHUB_STEP_SUMMARY | |
echo "| GUI | Drifty-GUI.pkg | $GUI_MACOS_PKG_SIZE |" >> $GITHUB_STEP_SUMMARY | |
echo "| GUI | Drifty-GUI.app | $GUI_MACOS_APP_SIZE |" >> $GITHUB_STEP_SUMMARY | |
echo "### Artifacts :package: Generated for Windows :window:" >> $GITHUB_STEP_SUMMARY | |
echo "| Application Type | Artifact Name | Size |" >> $GITHUB_STEP_SUMMARY | |
echo "|------------------|---------------|------|" >> $GITHUB_STEP_SUMMARY | |
echo "| CLI | Drifty-CLI.exe | $CLI_WINDOWS_SIZE |" >> $GITHUB_STEP_SUMMARY | |
echo "| GUI | Drifty-GUI.msi | $GUI_WINDOWS_MSI_SIZE |" >> $GITHUB_STEP_SUMMARY | |
echo "| GUI | Drifty-GUI.exe | $GUI_WINDOWS_EXE_SIZE |" >> $GITHUB_STEP_SUMMARY | |
if [ ${{ !inputs.create_release }} ]; then | |
echo "## Release :bookmark: Drifty v$VERSION" >> $GITHUB_STEP_SUMMARY | |
echo "Release Skipped :no_entry_sign:!" >> $GITHUB_STEP_SUMMARY | |
fi | |
- name: Create Release with automated release notes | |
if: ${{ inputs.create_release }} | |
run: | | |
echo "## Release :bookmark: Drifty v$VERSION" >> $GITHUB_STEP_SUMMARY | |
gh release create v$VERSION --generate-notes 'linux/build/CLI/Drifty-CLI_linux#Drifty-CLI_linux' 'linux/build/GUI/Drifty-GUI_linux#Drifty-GUI_linux' 'macos/build/CLI/Drifty-CLI_macos#Drifty-CLI_macos' 'macos/build/GUI/Drifty-GUI.pkg#Drifty-GUI.pkg' 'windows/build/CLI/Drifty-CLI.exe#Drifty-CLI.exe' 'windows/build/GUI/Drifty-GUI.msi#Drifty-GUI.msi' 'windows/build/GUI/Drifty-GUI.exe#Drifty-GUI.exe' | |
echo "[Released :white_check_mark: Drifty v$VERSION](https://github.com/SaptarshiSarkar12/Drifty/releases/tag/v$VERSION) successfully :rocket:!" >> $GITHUB_STEP_SUMMARY | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |