diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index beba9ec..fda0533 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,9 @@ name: Build MudletBootstrap on: push: - branches: [master] + branches: [master, development] + tags: + - 'v*' # Add tag trigger for releases pull_request: workflow_dispatch: @@ -164,13 +166,13 @@ jobs: - name: (Windows) Login to Azure uses: azure/login@v2 - if: runner.os == 'Windows' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' + if: runner.os == 'Windows' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' && github.repository == 'Mudlet/Mudlet' with: creds: ${{ secrets.AZURE_CREDENTIALS }} - name: Get Azure access token for code signing shell: pwsh - if: runner.os == 'Windows' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' + if: runner.os == 'Windows' && github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' && github.repository == 'Mudlet/Mudlet' run: | $token = (az account get-access-token --resource https://codesigning.azure.net | ConvertFrom-Json).accessToken "::add-mask::$token" @@ -206,3 +208,112 @@ jobs: name: ${{env.UPLOAD_FILENAME}} path: ${{env.FOLDER_TO_UPLOAD}} + release: + if: startsWith(github.ref, 'refs/tags/') + needs: compile + runs-on: ubuntu-latest + + steps: + - name: Checkout Source (for GameList.txt) + uses: actions/checkout@v5 + + - name: Download all platform artifacts + uses: actions/download-artifact@v4 + with: + path: ./platform-artifacts + + - name: Organize launchers by game + run: | + chmod +x $GITHUB_WORKSPACE/CI/organize-launchers.sh + $GITHUB_WORKSPACE/CI/organize-launchers.sh + + - name: Generate release body + run: | + echo "=== Generating release body ===" + + # Get repository and tag info + REPO="${{ github.repository }}" + TAG="${{ github.ref_name }}" + BASE_URL="https://github.com/$REPO/releases/download/$TAG" + + echo "Base URL: $BASE_URL" + + # Start building the release body + cat > release-body.md << 'EOF' + ## MudletBootstrap Release ${{ github.ref_name }} + + Choose your game below and download the appropriate file for your operating system: + + EOF + + # Add each game as a section + if [ -d "organized-releases" ]; then + for game_dir in organized-releases/*/; do + if [ -d "$game_dir" ]; then + game_name=$(basename "$game_dir") + echo "### $game_name" >> release-body.md + echo "" >> release-body.md + + # Check for each platform + windows_file=$(find "$game_dir" -name "*Windows.exe" | head -1) + macos_file=$(find "$game_dir" -name "*macOS.dmg" | head -1) + linux_file=$(find "$game_dir" -name "*Linux.AppImage.tar" | head -1) + + if [ -n "$windows_file" ]; then + filename=$(basename "$windows_file") + echo "- **Windows**: [\`$filename\`]($BASE_URL/$filename)" >> release-body.md + fi + + if [ -n "$macos_file" ]; then + filename=$(basename "$macos_file") + echo "- **macOS**: [\`$filename\`]($BASE_URL/$filename)" >> release-body.md + fi + + if [ -n "$linux_file" ]; then + filename=$(basename "$linux_file") + echo "- **Linux**: [\`$filename\`]($BASE_URL/$filename)" >> release-body.md + fi + + echo "" >> release-body.md + fi + done + fi + + # Add installation instructions + cat >> release-body.md << 'EOF' + ## Installation Instructions + + ### Windows + 1. Download the `.exe` file for your game + 2. Run MudletBootstrap - it'll download & install Mudlet for you + 3. You can delete MudletBootstrap after - Mudlet is all set up to play your favourite game. + + ### macOS + 1. Download the `.dmg` file for your game + 2. Open the DMG file + 3. Runt he MudletBootstrap app from within the mounted DMG + + ### Linux + 1. Download the `.AppImage.tar` file for your game + 2. Extract it: `tar -xf MudletBootstrap-[game]-Linux.AppImage.tar` + 2. Extract and run the AppImage within: `MudletBootstrap-[game].AppImage` + 3. You can delete MudletBootstrap after - Mudlet is all set up to play your favourite + EOF + + echo "Generated release body:" + cat release-body.md + + - name: Create Release with Game Organization + uses: softprops/action-gh-release@v1 + with: + files: organized-releases/**/* + tag_name: ${{ github.ref_name }} + name: MudletBootstrap ${{ github.ref_name }} + body_path: release-body.md + draft: false + prerelease: false + generate_release_notes: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + diff --git a/CI/deploy-win.sh b/CI/deploy-win.sh index be52d69..51f2e43 100644 --- a/CI/deploy-win.sh +++ b/CI/deploy-win.sh @@ -58,6 +58,16 @@ if [[ ! -d "$uploadDirUnix" ]]; then mkdir -p "$uploadDirUnix" fi +# Check if this is a tagged release +IS_RELEASE=false +if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + IS_RELEASE=true + echo "=== Building for RELEASE ===" + mkdir -p "${GITHUB_WORKSPACE_UNIX_PATH}/extracted-games" +else + echo "=== Building for regular build ===" +fi + # Set up Java for code signing if Azure token is available if [ -n "${AZURE_ACCESS_TOKEN}" ]; then echo "=== Setting up Java 21 for signing ===" @@ -102,10 +112,23 @@ while IFS= read -r line || [[ -n "$line" ]]; do #rsync -avR "${PACKAGE_DIR}"/./* "$uploadDirUnix" cp -r "${PACKAGE_DIR}/"* "$uploadDirUnix" + # If this is a release, also copy to extracted-games with standardized naming + if [ "$IS_RELEASE" = true ]; then + echo "Creating release version for $gameName" + mkdir -p "${GITHUB_WORKSPACE_UNIX_PATH}/extracted-games/$gameName" + cp "${PACKAGE_DIR}/MudletBootstrap-${gameName}.exe" \ + "${GITHUB_WORKSPACE_UNIX_PATH}/extracted-games/$gameName/MudletBootstrap-$gameName-Windows.exe" + fi + cd "$GITHUB_WORKSPACE" || exit 1 done < "${GITHUB_WORKSPACE}/GameList.txt" +if [ "$IS_RELEASE" = true ]; then + echo "=== Release files created ===" + find "${GITHUB_WORKSPACE_UNIX_PATH}/extracted-games" -type f | sort +fi + # Append these variables to the GITHUB_ENV to make them available in subsequent steps { echo "FOLDER_TO_UPLOAD=${uploadDir}\\" diff --git a/CI/organize-launchers.sh b/CI/organize-launchers.sh new file mode 100644 index 0000000..8071092 --- /dev/null +++ b/CI/organize-launchers.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +echo "=== Organizing launchers by game ===" + +echo "Listing files in ./platform-artifacts" +ls ./platform-artifacts + +# Create organized structure +mkdir -p organized-releases + +# Look for extracted-games directories in the downloaded artifacts +echo "Searching for extracted-games directories..." +find ./platform-artifacts -name "extracted-games" -type d | while read extracted_dir; do + echo "Found extracted-games directory: $extracted_dir" + if [ -d "$extracted_dir" ]; then + # Copy all game directories from this platform's extracted-games + cp -r "$extracted_dir"/* organized-releases/ 2>/dev/null || true + fi +done + +# If no extracted-games directories found, look for game files in the artifact directories directly +if [ ! "$(ls -A organized-releases 2>/dev/null)" ]; then + echo "No extracted-games directories found, looking for game files in artifact directories..." + + # Check each platform artifact directory + for platform_dir in ./platform-artifacts/*/; do + if [ -d "$platform_dir" ]; then + platform_name=$(basename "$platform_dir") + echo "Checking platform directory: $platform_name" + + # Look for game launcher files + case "$platform_name" in + *MINGW64*|*Windows*) + echo " Looking for Windows executables..." + find "$platform_dir" -name "*.exe" -type f | while read launcher; do + if [ -f "$launcher" ]; then + filename=$(basename "$launcher") + echo " Found Windows launcher: $filename" + # Extract game name (format: MudletBootstrap-GameName.exe) + if [[ "$filename" =~ MudletBootstrap-(.+)\.exe$ ]]; then + gameName="${BASH_REMATCH[1]}" + echo " Game: $gameName" + mkdir -p "organized-releases/$gameName" + cp "$launcher" "organized-releases/$gameName/MudletBootstrap-$gameName-Windows.exe" + fi + fi + done + ;; + *macOS*) + echo " Looking for macOS DMG files..." + find "$platform_dir" -name "*.dmg" -type f | while read launcher; do + if [ -f "$launcher" ]; then + filename=$(basename "$launcher") + echo " Found macOS launcher: $filename" + # Extract game name (format: MudletBootstrap-GameName.dmg) + if [[ "$filename" =~ MudletBootstrap-(.+)\.dmg$ ]]; then + gameName="${BASH_REMATCH[1]}" + echo " Game: $gameName" + mkdir -p "organized-releases/$gameName" + cp "$launcher" "organized-releases/$gameName/MudletBootstrap-$gameName-macOS.dmg" + fi + fi + done + ;; + *linux*) + echo " Looking for Linux AppImage files..." + find "$platform_dir" -name "*.AppImage.tar" -type f | while read launcher; do + if [ -f "$launcher" ]; then + filename=$(basename "$launcher") + echo " Found Linux launcher: $filename" + # Extract game name (format: MudletBootstrap-linux-x64-GameName.AppImage.tar) + if [[ "$filename" =~ MudletBootstrap-linux-x64-(.+)\.AppImage\.tar$ ]]; then + gameName="${BASH_REMATCH[1]}" + echo " Game: $gameName" + mkdir -p "organized-releases/$gameName" + cp "$launcher" "organized-releases/$gameName/MudletBootstrap-$gameName-Linux.AppImage.tar" + fi + fi + done + ;; + esac + fi + done +fi + +echo "Final organized structure:" +find organized-releases -type f | sort diff --git a/CI/package-linux.sh b/CI/package-linux.sh index 3bb7843..07509fc 100644 --- a/CI/package-linux.sh +++ b/CI/package-linux.sh @@ -25,6 +25,16 @@ fi mkdir "${GITHUB_WORKSPACE}/upload/" +# Check if this is a tagged release +IS_RELEASE=false +if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + IS_RELEASE=true + echo "=== Building for RELEASE ===" + mkdir -p "${GITHUB_WORKSPACE}/extracted-games" +else + echo "=== Building for regular build ===" +fi + echo "Working in directory:" pwd @@ -67,6 +77,14 @@ while IFS= read -r line || [[ -n "$line" ]]; do mv "MudletBootstrap-linux-x64.AppImage.tar" "${GITHUB_WORKSPACE}/upload/MudletBootstrap-linux-x64-${gameName}.AppImage.tar" + # If this is a release, also copy to extracted-games with standardized naming + if [ "$IS_RELEASE" = true ]; then + echo "Creating release version for $gameName" + mkdir -p "${GITHUB_WORKSPACE}/extracted-games/$gameName" + cp "${GITHUB_WORKSPACE}/upload/MudletBootstrap-linux-x64-${gameName}.AppImage.tar" \ + "${GITHUB_WORKSPACE}/extracted-games/$gameName/MudletBootstrap-$gameName-Linux.AppImage.tar" + fi + rm -rf app/ done < "${GITHUB_WORKSPACE}/GameList.txt" @@ -75,6 +93,11 @@ echo "=== ... later, via Github ===" ls ${GITHUB_WORKSPACE}/upload +if [ "$IS_RELEASE" = true ]; then + echo "=== Release files created ===" + find "${GITHUB_WORKSPACE}/extracted-games" -type f | sort +fi + { echo "FOLDER_TO_UPLOAD=${GITHUB_WORKSPACE}/upload" echo "UPLOAD_FILENAME=MudletBootstrap-linux-x64" diff --git a/CI/package-mac.sh b/CI/package-mac.sh index 8a12b61..bf0cf97 100644 --- a/CI/package-mac.sh +++ b/CI/package-mac.sh @@ -94,6 +94,16 @@ npm install -g appdmg mkdir -p "${GITHUB_WORKSPACE}/upload/" +# Check if this is a tagged release +IS_RELEASE=false +if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + IS_RELEASE=true + echo "=== Building for RELEASE ===" + mkdir -p "${GITHUB_WORKSPACE}/extracted-games" +else + echo "=== Building for regular build ===" +fi + while IFS= read -r line || [[ -n "$line" ]]; do gameName=$(echo "$line" | tr -cd '[:alnum:]_-') appBaseName="MudletBootstrap" @@ -166,8 +176,21 @@ while IFS= read -r line || [[ -n "$line" ]]; do mv "${HOME}/Desktop/${appBaseName}.dmg" "${GITHUB_WORKSPACE}/upload/${appBaseName}-${gameName}.dmg" + # If this is a release, also copy to extracted-games with standardized naming + if [ "$IS_RELEASE" = true ]; then + echo "Creating release version for $gameName" + mkdir -p "${GITHUB_WORKSPACE}/extracted-games/$gameName" + cp "${GITHUB_WORKSPACE}/upload/${appBaseName}-${gameName}.dmg" \ + "${GITHUB_WORKSPACE}/extracted-games/$gameName/MudletBootstrap-$gameName-macOS.dmg" + fi + done < "${GITHUB_WORKSPACE}/GameList.txt" +if [ "$IS_RELEASE" = true ]; then + echo "=== Release files created ===" + find "${GITHUB_WORKSPACE}/extracted-games" -type f | sort +fi + { echo "FOLDER_TO_UPLOAD=${GITHUB_WORKSPACE}/upload" echo "UPLOAD_FILENAME=${appBaseName}-macOS" diff --git a/CI/package-win.sh b/CI/package-win.sh index 20ea11f..4eed737 100644 --- a/CI/package-win.sh +++ b/CI/package-win.sh @@ -118,7 +118,6 @@ while IFS= read -r line || [[ -n "$line" ]]; do ZIP_FILE_NAME="MudletBootstrap" - # To determine which system libraries have to be copied in it requires # continually trying to run the executable on the target type system # and adding in the libraries to the same directory and repeating that