Package #20
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: Package | |
on: | |
#push: | |
workflow_dispatch: | |
inputs: | |
version: | |
type: string | |
description: The version to publish | |
required: true | |
publish_github: | |
description: 'Create draft GitHub release' | |
default: true | |
type: boolean | |
jobs: | |
package: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 18.0.2 | |
distribution: 'zulu' | |
java-package: 'jdk+fx' | |
cache: 'maven' | |
- name: Build native installer | |
run: mvn clean install | |
- name: Upload native installer | |
uses: actions/upload-artifact@v4 | |
with: | |
name: J3-${{ runner.os }} | |
path: | | |
./target/*.msi | |
./target/*.dmg | |
./target/*.deb | |
- name: Create platform-independent bundle | |
if: runner.os == 'Linux' | |
run: | | |
pushd target | |
mkdir bundle | |
mkdir bundle/J3 | |
cp -r lib/ bundle/J3 | |
cp -r runtime/ bundle/J3 | |
cp -r ../data bundle/J3 | |
cp -r ../animations bundle/J3 | |
cp ../COPYING bundle/J3 | |
cp ../README.md bundle/J3 | |
cp ../src/packaging/j3.bat bundle/J3 | |
cp ../src/packaging/j3 bundle/J3 | |
chmod +x bundle/J3/j3 | |
- name: Upload platform-independent bundle | |
if: runner.os == 'Linux' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: J3 | |
path: | | |
./target/bundle | |
publish: | |
if: inputs.publish_github | |
runs-on: ubuntu-latest | |
needs: package | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
path: temp | |
- name: Install required software | |
run: | | |
sudo apt install xmlstarlet | |
- name: Get project settings | |
run: | | |
shortname=$(xmlstarlet sel -N x="http://maven.apache.org/POM/4.0.0" -t -v "//x:project/x:artifactId/text()" pom.xml) | |
version=$(xmlstarlet sel -N x="http://maven.apache.org/POM/4.0.0" -t -v "//x:project/x:version/text()" pom.xml) | |
echo "BUILD_NAME=${shortname}" >> $GITHUB_ENV | |
echo "BUILD_VERSION=${version}" >> $GITHUB_ENV | |
- name: Validate version number | |
run: | | |
[ "${{ inputs.version }}" == "${BUILD_VERSION}" ] || (>&2 echo "Version does not match value in pom.xml"; exit -1) | |
- name: Stage content | |
run: | | |
mkdir release | |
cp temp/J3-Windows/* release | |
cp temp/J3-Linux/* release | |
zip -r release/J3.zip temp/J3 | |
- name: Stage GitHub release | |
run: | | |
gh release create "v${{ inputs.version }}" --draft --title "Version ${{ inputs.version }}" release/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |