Files
AppleCommander/.github/workflows/build.yml
T

316 lines
9.8 KiB
YAML

name: AppleCommander builds
on:
push:
branches: [ "main" ]
tags:
- '*'
pull_request:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
jobs:
build-java:
name: Java build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 25
uses: actions/setup-java@v6.0.0
with:
java-version: '25'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Build with Gradle
env:
# The SWT image tests fail in the pipeline; disable them.
AC_SKIP_SWT_TESTS: true
run: ./gradlew build
- name: Upload 'ac'
uses: actions/upload-artifact@v7
with:
name: build-artifacts
path: app/cli-ac/build/libs/AppleCommander-ac*
archive: false
if-no-files-found: error
- name: Upload 'acx'
uses: actions/upload-artifact@v7
with:
name: build-artifacts
path: app/cli-acx/build/libs/AppleCommander-acx*
archive: false
if-no-files-found: error
- name: Upload MacOS aarch64
uses: actions/upload-artifact@v7
with:
name: build-artifacts
path: app/gui-swt-macosx-aarch64/build/libs/AppleCommander*.jar
archive: false
if-no-files-found: error
- name: Upload MacOS x86_64
uses: actions/upload-artifact@v7
with:
name: build-artifacts
path: app/gui-swt-macosx-x86_64/build/libs/AppleCommander*.jar
archive: false
if-no-files-found: error
- name: Upload Linux x86_64
uses: actions/upload-artifact@v7
with:
name: build-artifacts
path: app/gui-swt-linux-x86_64/build/libs/AppleCommander*.jar
archive: false
if-no-files-found: error
- name: Upload Linux ARM (Raspberry Pi?)
uses: actions/upload-artifact@v7
with:
name: build-artifacts
path: app/gui-swt-linux-arm/build/libs/AppleCommander*.jar
archive: false
if-no-files-found: error
- name: Upload Linux aarch64
uses: actions/upload-artifact@v7
with:
name: build-artifacts
path: app/gui-swt-linux-aarch64/build/libs/AppleCommander*.jar
archive: false
if-no-files-found: error
- name: Upload Windows x86_64
uses: actions/upload-artifact@v7
with:
name: build-artifacts
path: app/gui-swt-win32-x86_64/build/libs/AppleCommander*.jar
archive: false
if-no-files-found: error
# This is a crude license header check. The ones I tested were susceptible to whitespace differences
# and I never got them to work. My primary goal is to ensure the headers exist, so this suffices.
license-check:
name: License check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Look for license phrase
run: |
outfile=$(mktemp)
find . -name "*.java" -not -name "Sleak.java" | xargs grep -L "GNU General Public License" > ${outfile}
if [ -s "${outfile}" ]
then
echo "License headers missing on the following files:"
cat ${outfile}
exit 1
else
echo "License headers appear to be valid!"
fi
build-jpackage:
name: jpackage on ${{ matrix.os }}-${{ matrix.arch }}
needs: [build-java, license-check]
runs-on: ${{ matrix.label }}
strategy:
matrix:
include:
- label: ubuntu-latest
os: linux
arch: x86_64
path: app/gui-swt-linux-x86_64
- label: ubuntu-24.04-arm
os: linux
arch: aarch64
path: app/gui-swt-linux-aarch64
- label: windows-latest
os: windows
arch: x86_64
path: app\gui-swt-win32-x86_64
- label: macos-15-intel
os: darwin
arch: x86_64
path: app/gui-swt-macosx-x86_64
- label: macos-15
os: darwin
arch: arm64
path: app/gui-swt-macosx-aarch64
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 25
uses: actions/setup-java@v6.0.0
with:
java-version: '25'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Build with Gradle
# Skipping all tests. SWT image tests fail in the pipeline and ANT tests fail under Windows.
run: ./gradlew build -x test
- name: Create DMG file (MacOS)
if: runner.os == 'macOS'
run: ./scripts/build-macos-dmg.sh ${{ matrix.path }}
- name: Create MSI file (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
dotnet tool install --global wix --version 5
wix extension add -g WixToolset.Util.wixext/5.0.0
wix extension add -g WixToolset.Ui.wixext/5.0.0
.\scripts\build-windows-msi.ps1 ${{ matrix.path }}
- name: Create DEB file (Linux)
if: runner.os == 'Linux'
run: ./scripts/build-linux-deb.sh ${{ matrix.path }}
- name: Create RPM file (Linux)
if: runner.os == 'Linux'
run: |
sudo apt install -y rpm
./scripts/build-linux-rpm.sh ${{ matrix.path }}
- name: Upload DMG
if: runner.os == 'macOS'
uses: actions/upload-artifact@v7
with:
path: AppleCommander-*.dmg
archive: false
if-no-files-found: error
- name: Upload MSI
if: runner.os == 'Windows'
uses: actions/upload-artifact@v7
with:
path: AppleCommander-*.msi
archive: false
if-no-files-found: error
- name: Upload DEB
if: runner.os == 'Linux'
uses: actions/upload-artifact@v7
with:
path: AppleCommander-*.deb
archive: false
if-no-files-found: error
- name: Upload RPM
if: runner.os == 'Linux'
uses: actions/upload-artifact@v7
with:
path: AppleCommander-*.rpm
archive: false
if-no-files-found: error
build-native:
name: ac/acx on ${{ matrix.os }}-${{ matrix.arch }}
needs: [build-jpackage]
runs-on: ${{ matrix.label }}
strategy:
matrix:
# See: https://docs.github.com/en/actions/concepts/runners/about-github-hosted-runners#overview-of-github-hosted-runners
# ... and follow the links to the related GitHub repositories
include:
- label: ubuntu-latest
os: linux
arch: x86_64
- label: ubuntu-24.04-arm
os: linux
arch: aarch64
- label: windows-latest
os: windows
arch: x86_64
- label: macos-15-intel
os: darwin
arch: x86_64
- label: macos-15
os: darwin
arch: arm64
steps:
- uses: actions/checkout@v7
- uses: graalvm/setup-graalvm@v1
with:
java-version: '25'
distribution: 'liberica'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Build ac/acx
run: ./gradlew nativeCompile
env:
# Needed for Windows; not an issue for other OSes
GRADLE_OPTS: -Djava.io.tmpdir=${{ runner.temp }}
- name: Run UPX
uses: crazy-max/ghaction-upx@v4
if: runner.os == 'Linux'
with:
files: |
app/cli-ac/build/native/nativeCompile/ac-*
app/cli-acx/build/native/nativeCompile/acx-*
- name: Run CLTH tests
if: ${{ matrix.os != 'windows' }}
shell: bash
run: ./scripts/run-clth-tests.sh
- name: Upload binary
uses: actions/upload-artifact@v7
with:
name: ac-${{ matrix.os }}-${{ matrix.arch }}
path: app/cli-ac/build/native/nativeCompile/ac-*
archive: false
- name: Upload binary
uses: actions/upload-artifact@v7
with:
name: acx-${{ matrix.os }}-${{ matrix.arch }}
path: app/cli-acx/build/native/nativeCompile/acx-*
archive: false
release:
name: Create draft release
if: github.ref_type == 'tag'
needs: [build-java, build-jpackage, build-native]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v8
with:
merge-multiple: true
- uses: softprops/action-gh-release@v3
with:
draft: true
generate_release_notes: true
files: |
ac-*
acx-*
AppleCommander-*
publish:
name: Publish to Maven Central
if: github.ref_type == 'tag'
needs: [build-java, build-jpackage, build-native]
runs-on: ubuntu-latest
steps:
- name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
- name: Setup .netrc file
uses: extractions/netrc@v3
with:
machine: ossrh-staging-api.central.sonatype.com
username: ${{ secrets.OSSRH_USERNAME }}
password: ${{ secrets.OSSRH_TOKEN }}
- name: Checkout code
uses: actions/checkout@v7
- name: Set up JDK 25
uses: actions/setup-java@v6.0.0
with:
java-version: '25'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Publish with Gradle
run: >
./gradlew
-PossrhUsername="${{ secrets.OSSRH_USERNAME }}"
-PossrhPassword="${{ secrets.OSSRH_TOKEN }}"
-Psigning.keyId="${{ secrets.GPG_SIGNING_KEY }}"
-Psigning.password="${{ secrets.GPG_SIGNING_PASSPHRASE }}"
-Psigning.secretKeyRingFile=/home/runner/.gnupg/trustdb.gpg
build publish -x test
- name: Finish publishing
run: ./scripts/finish-publishing.sh