Skip to content

Release

Release #167

# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Release
on:
workflow_dispatch:
inputs:
release_type:
description: 'Release Type'
required: true
type: choice
default: "Alpha"
options:
- "Production"
- "Alpha"
version_override:
description: 'Version Override'
required: false
type: string
default: ""
jobs:
release:
environment: deploy
runs-on: ubuntu-latest
env:
INSTALL4J_DIR: "install4j/install4j10.0.6"
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: 21.0.1
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Run Checks
run: xvfb-run --auto-servernum ./gradlew --stacktrace -PjavafxPlatform=linux check
env:
JAVA_TOOL_OPTIONS: "-Dprism.verbose=true -Dprism.order=sw"
- name: Set Version
id: set_version
run: |
tagPrefix=$(date +%Y.%-m)
count=0
baseTag=$tagPrefix.$count
git fetch --tags
while [[ $(git tag -l "v$baseTag") ]]
do
count=$(($count+1));
baseTag=$tagPrefix.$count;
done
if [[ "${{ github.event.inputs.release_type }}" == "Alpha" ]]; then
baseTag=$baseTag-alpha
elif [[ "${{ github.event.inputs.release_type }}" == "Experimental" ]]; then
baseTag=$baseTag-experimental
fi
if [[ "${{ github.event.inputs.release_type }}" != "Production" ]]; then
count=1
tag=$baseTag-$count
while [[ $(git tag -l "v$tag") ]]
do
count=$(($count+1));
tag=$baseTag-$count;
done
else
tag=$baseTag
fi
if [[ "${{ github.event.inputs.version_override }}" != "" ]]; then
tag=${{ github.event.inputs.version_override }}
fi
echo ::set-output name=tag::$tag
- name: Download Install4j
run: |
mkdir -p "$HOME/install4j"
curl https://content.faforever.com/build/install4j_unix_10_0_6.tar.gz -o "$HOME/install4j/install4j.tar.gz"
tar xzf "$HOME/install4j/install4j.tar.gz" -C "$HOME/install4j"
- name: Download Bundled JRE
run: |
mkdir -p "$HOME/.local/share/install4j/v10/jres"
curl https://content.faforever.com/build/jre/windows-amd64-21.0.1.tar.gz -o "$HOME/.local/share/install4j/v10/jres/windows-amd64-21.0.1.tar.gz"
- name: Build Windows Files
run: |
./gradlew -Pversion="${{ steps.set_version.outputs.tag }}" \
-PjavafxPlatform=win \
-Pinstall4jHomeDir=$HOME/$INSTALL4J_DIR \
-Pinstall4jLicense=${{ secrets.INSTALL4J_LICENSE }} \
--info \
--stacktrace \
buildInstall4jMediaFiles
- name: Build Linux Files
run: |
./gradlew -Pversion="${{ steps.set_version.outputs.tag }}" \
-PjavafxPlatform=linux \
-Pinstall4jHomeDir=$HOME/$INSTALL4J_DIR \
-Pinstall4jLicense=${{ secrets.INSTALL4J_LICENSE }} \
--info \
--stacktrace \
buildInstall4jMediaFiles
- name: Get Artifact Paths
id: artifact_paths
run: |
WINDOWS_EXE=$(ls build/install4j/faf_windows-x64_*.exe | head -n 1)
WINDOWS_EXE_NAME=$(basename $WINDOWS_EXE)
echo ::set-output name=WINDOWS_EXE::${WINDOWS_EXE}
echo ::set-output name=WINDOWS_EXE_NAME::${WINDOWS_EXE_NAME}
- name: Create Draft Release
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit: ${{ github.sha }}
tag: v${{ steps.set_version.outputs.tag }}
draft: true
prerelease: ${{ github.event.inputs.release_type != 'Production'}}
generateReleaseNotes: true
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: build/install4j/faf_*
- name: Upload to Mirror
if: github.event.inputs.release_type == 'Production'
uses: bayssmekanique/action-simple-file-upload@v1
with:
user: ${{ secrets.FTP_MIRROR_USERNAME }}
password: ${{ secrets.FTP_MIRROR_PASSWORD }}
host: ${{ secrets.FTP_MIRROR_HOST }}
src: ${{ steps.artifact_paths.outputs.WINDOWS_EXE }}
dest: ${{ steps.artifact_paths.outputs.WINDOWS_EXE_NAME }}