Skip to content

Build

Build #392

Workflow file for this run

# 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: Build
on:
workflow_dispatch:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build-jar:
if: |
contains(github.event_name, 'workflow_dispatch') ||
contains(github.event.head_commit.message, '[trigger-nightly-build]')
runs-on: ubuntu-latest
permissions: write-all
outputs:
project-version: ${{ steps.bump-version.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package
- name: Extract Maven project version
run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT
id: bump-version
- name: Rename artifact core to contain "nightly"
run: mv nqueensfaf-core/target/nqueensfaf-core-${{ steps.bump-version.outputs.version }}.jar nqueensfaf-core/target/nqueensfaf-core-${{ steps.bump-version.outputs.version }}-nightly.jar
- name: Rename artifact impl to contain "nightly"
run: mv nqueensfaf-impl/target/nqueensfaf-impl-${{ steps.bump-version.outputs.version }}.jar nqueensfaf-impl/target/nqueensfaf-impl-${{ steps.bump-version.outputs.version }}-nightly.jar
- name: Upload artifact core to nightly release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload nightly nqueensfaf-core/target/nqueensfaf-core-${{ steps.bump-version.outputs.version }}-nightly.jar --clobber
- name: Upload artifact impl to nightly release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload nightly nqueensfaf-impl/target/nqueensfaf-impl-${{ steps.bump-version.outputs.version }}-nightly.jar --clobber
- name: Submit Dependency Snapshot
uses: advanced-security/maven-dependency-submission-action@v3
build-linux:
runs-on: ubuntu-latest
needs: build-jar
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package
- name: Extract lwjgl native shared library
run: |
cd nqueensfaf-demo/target
7z e nqueensfaf-demo-${{ needs.build-jar.outputs.project-version }}.jar linux/x64/org/lwjgl/liblwjgl.so
- name: Upload shared library
uses: actions/upload-artifact@v3
with:
name: lwjgl-linux-native
path: nqueensfaf-demo/target/liblwjgl.so
retention-days: 1
build-macos:
runs-on: macos-latest
needs: build-jar
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package
- name: Extract lwjgl native shared library
run: |
cd nqueensfaf-demo/target
7z e nqueensfaf-demo-${{ needs.build-jar.outputs.project-version }}.jar macos/arm64/org/lwjgl/liblwjgl.dylib
- name: Upload shared library
uses: actions/upload-artifact@v3
with:
name: lwjgl-macos-native
path: nqueensfaf-demo/target/liblwjgl.dylib
retention-days: 1
build-windows:
runs-on: windows-latest
needs: build-jar
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package
- name: Extract lwjgl native shared library
run: |
cd nqueensfaf-demo/target
7z e nqueensfaf-demo-${{ needs.build-jar.outputs.project-version }}.jar windows/x64/org/lwjgl/lwjgl.dll
- name: Upload shared library
uses: actions/upload-artifact@v3
with:
name: lwjgl-windows-native
path: nqueensfaf-demo/target/lwjgl.dll
retention-days: 1
build-demo:
runs-on: ubuntu-latest
needs: [build-jar, build-linux, build-macos, build-windows]
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package
- name: Download lwjgl natives
uses: actions/download-artifact@v3
- name: Inject lwjgl natives into runnable jar
run: |
mkdir -p nqueensfaf-demo/target/macos/x64/org/lwjgl
mkdir -p nqueensfaf-demo/target/windows/x64/org/lwjgl
mv lwjgl-macos-native/liblwjgl.dylib nqueensfaf-demo/target/macos/x64/org/lwjgl
mv lwjgl-windows-native/lwjgl.dll nqueensfaf-demo/target/windows/x64/org/lwjgl
cd nqueensfaf-demo/target
7z a nqueensfaf-demo-${{ needs.build-jar.outputs.project-version }}.jar macos windows
- name: Rename artifact to contain "nightly"
run: mv nqueensfaf-demo/target/nqueensfaf-demo-${{ needs.build-jar.outputs.project-version }}.jar nqueensfaf-demo/target/nqueensfaf-demo-${{ needs.build-jar.outputs.project-version }}-nightly.jar
- name: Upload artifact to nightly release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload nightly nqueensfaf-demo/target/nqueensfaf-demo-${{ needs.build-jar.outputs.project-version }}-nightly.jar --clobber
update-nightly-tag:
runs-on: ubuntu-latest
needs: [build-jar, build-demo]
steps:
#- name: Delete release drafts
# uses: hugo19941994/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update nightly tag
uses: richardsimko/update-tag@v1
with:
tag_name: nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}