Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 45 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
tags:
- "v*"
workflow_dispatch:
inputs:
release_tag:
description: "Release tag to publish (for example: v1.2.3)"
required: true
type: string

permissions:
contents: write
Expand All @@ -28,7 +33,7 @@ jobs:
output_ext: exe
- name: macos
os: macos-latest
package_type: dmg
package_type: app-image
icon: assets/icons/flaggi.icns
output_ext: dmg
- name: linux
Expand Down Expand Up @@ -61,12 +66,24 @@ jobs:
}
"$wixBin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Install create-dmg (macOS)
if: runner.os == 'macOS'
shell: bash
run: brew install create-dmg

- name: Resolve version
shell: bash
run: |
set -euo pipefail
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
VERSION="${GITHUB_REF_NAME#v}"
elif [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
TAG="${{ github.event.inputs.release_tag }}"
if [[ ! "$TAG" =~ ^v.+ ]]; then
echo "Manual dispatch requires a tag starting with 'v' (got: $TAG)" >&2
exit 1
fi
VERSION="${TAG#v}"
else
VERSION="$(grep '^version=' gradle.properties | cut -d= -f2)"
fi
Expand All @@ -92,12 +109,22 @@ jobs:
JAR_FILE="client/build/libs/flaggi-client.jar"
DIST_DIR="dist"
RUNTIME_DIR="build/jre"
DMG_BACKGROUND="assets/banners/dmg-background.png"
JPACKAGE_DEST="$DIST_DIR"
PACKAGE_TYPE="${{ matrix.target.package_type }}"

test -f "$JAR_FILE"

rm -rf "$RUNTIME_DIR" "$DIST_DIR"
mkdir -p "$DIST_DIR"

if [[ "${{ matrix.target.name }}" == "macos" ]]; then
JPACKAGE_DEST="build/app-image"
rm -rf "$JPACKAGE_DEST"
mkdir -p "$JPACKAGE_DEST"
test -f "$DMG_BACKGROUND"
fi

MODULES=$(jdeps --multi-release 21 --print-module-deps --ignore-missing-deps "$JAR_FILE")

jlink \
Expand All @@ -112,8 +139,8 @@ jobs:
--main-jar "flaggi-client.jar"
--name "$APP_NAME"
--app-version "$APP_VERSION"
--type "${{ matrix.target.package_type }}"
--dest "$DIST_DIR"
--type "$PACKAGE_TYPE"
--dest "$JPACKAGE_DEST"
--runtime-image "$RUNTIME_DIR"
--icon "${{ matrix.target.icon }}"
)
Expand All @@ -131,9 +158,20 @@ jobs:
mv "$src_file" "$out_file"
;;
macos)
src_file=$(find "$DIST_DIR" -maxdepth 1 -name '*.dmg' -print -quit)
out_file="$DIST_DIR/Flaggi-${APP_VERSION}-macos.dmg"
mv "$src_file" "$out_file"
rm -f "$out_file"
create-dmg \
--volname "$APP_NAME" \
--volicon "${{ matrix.target.icon }}" \
--background "$DMG_BACKGROUND" \
--window-pos 200 120 \
--window-size 660 400 \
--icon-size 100 \
--icon "${APP_NAME}.app" 165 190 \
--hide-extension "${APP_NAME}.app" \
--app-drop-link 495 190 \
"$out_file" \
"$JPACKAGE_DEST"
;;
linux)
tar -C "$DIST_DIR" -czf "$DIST_DIR/Flaggi-${APP_VERSION}-linux.tar.gz" "$APP_NAME"
Expand All @@ -153,7 +191,7 @@ jobs:
publish:
name: Publish GitHub Release
needs: package
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest

steps:
Expand All @@ -165,5 +203,6 @@ jobs:
- name: Publish release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || github.event.inputs.release_tag }}
files: release-artifacts/**/**
generate_release_notes: true
Loading