Jab at fix google auth local host adress #208
This file contains hidden or 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: Build & Release (dev) | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: build-release-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-android: | |
| name: Build Android APK | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| cache: gradle | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.44.0' | |
| channel: stable | |
| cache: true | |
| - name: Cache pub dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.pub-cache | |
| key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub- | |
| - name: Prepare signing keystore | |
| env: | |
| ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
| KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
| KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
| KEY_ALIAS: ${{ secrets.KEY_ALIAS || 'release' }} | |
| run: | | |
| if [ -z "$ANDROID_KEYSTORE_BASE64" ]; then | |
| echo "Missing ANDROID_KEYSTORE_BASE64 in GitHub Secrets." | |
| exit 1 | |
| fi | |
| if [ -z "$KEYSTORE_PASSWORD" ] || [ -z "$KEY_PASSWORD" ]; then | |
| echo "Missing KEYSTORE_PASSWORD or KEY_PASSWORD in GitHub Secrets." | |
| exit 1 | |
| fi | |
| TEMP_KEYSTORE_PATH="$(mktemp)" | |
| trap 'rm -f "$TEMP_KEYSTORE_PATH"' EXIT | |
| if ! echo "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$TEMP_KEYSTORE_PATH"; then | |
| echo "Failed to decode ANDROID_KEYSTORE_BASE64. Verify it is valid base64 in GitHub Secrets." | |
| exit 1 | |
| fi | |
| if ! mv "$TEMP_KEYSTORE_PATH" android/app-release.jks; then | |
| echo "Failed to write decoded keystore to android/app-release.jks. Verify the android directory is writable." | |
| exit 1 | |
| fi | |
| if ! printf '%s\n' "$KEYSTORE_PASSWORD" | keytool -list -keystore android/app-release.jks >/dev/null 2>&1; then | |
| rm -f android/app-release.jks | |
| echo "Keystore validation failed. Verify android/app-release.jks is a readable keystore file and KEYSTORE_PASSWORD is correct for it." | |
| exit 1 | |
| fi | |
| if ! printf '%s\n' "$KEYSTORE_PASSWORD" | keytool -list -keystore android/app-release.jks -alias "$KEY_ALIAS" >/dev/null 2>&1; then | |
| rm -f android/app-release.jks | |
| echo "Keystore alias validation failed. Verify KEY_ALIAS exists in the configured keystore." | |
| exit 1 | |
| fi | |
| chmod 600 android/app-release.jks | |
| umask 077 | |
| printf 'storePassword=%s\nkeyPassword=%s\nkeyAlias=%s\nstoreFile=app-release.jks\n' \ | |
| "$KEYSTORE_PASSWORD" "$KEY_PASSWORD" "$KEY_ALIAS" > android/key.properties | |
| chmod 600 android/key.properties | |
| - name: Build APK | |
| run: flutter build apk --release | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: android-apk | |
| path: build/app/outputs/flutter-apk/app-release.apk | |
| build-windows: | |
| name: Build Windows EXE | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.44.0' | |
| channel: stable | |
| cache: false | |
| - name: Cache pub dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/AppData/Local/Pub/Cache | |
| key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub- | |
| - name: Setup CMake 3.x | |
| uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: '3.31.6' | |
| - name: Build Windows | |
| run: flutter build windows --release | |
| env: | |
| CMAKE_POLICY_VERSION_MINIMUM: "3.5" | |
| - name: Build MSIX | |
| run: dart run msix:create | |
| - name: Zip Windows build | |
| shell: pwsh | |
| run: | | |
| Compress-Archive -Path build/windows/x64/runner/Release/* -DestinationPath MCCompanion-windows.zip | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: windows-zip | |
| path: MCCompanion-windows.zip | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: windows-msix | |
| path: build/windows/x64/runner/Release/MCCompanion.msix | |
| build-macos: | |
| name: Build macOS DMG | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.44.0' | |
| channel: stable | |
| cache: true | |
| - name: Cache pub dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.pub-cache | |
| key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub- | |
| - name: Cache CocoaPods | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.cocoapods/repos | |
| ~/Library/Caches/CocoaPods | |
| macos/Pods | |
| key: ${{ runner.os }}-cocoapods-${{ hashFiles('macos/Podfile.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cocoapods- | |
| - name: Prepare macOS dependency overrides | |
| run: | | |
| cat > pubspec_overrides.yaml <<'EOF' | |
| dependency_overrides: | |
| connectivity_plus: 6.1.4 | |
| EOF | |
| flutter pub get | |
| - name: Build macOS | |
| run: flutter build macos --release | |
| env: | |
| FLUTTER_XCODE_CODE_SIGNING_ALLOWED: "NO" | |
| FLUTTER_XCODE_CODE_SIGN_IDENTITY: "" | |
| FLUTTER_XCODE_CODE_SIGNING_REQUIRED: "NO" | |
| - name: Ad-hoc sign macOS app | |
| run: | | |
| APP_PATH="build/macos/Build/Products/Release/MCCompanion.app" | |
| codesign --force --deep --sign - "$APP_PATH" | |
| codesign --verify --deep --strict "$APP_PATH" | |
| - name: Create macOS DMG | |
| run: | | |
| STAGING_DIR="$RUNNER_TEMP/dmg-staging" | |
| APP_PATH="build/macos/Build/Products/Release/MCCompanion.app" | |
| rm -rf "$STAGING_DIR" | |
| mkdir -p "$STAGING_DIR" | |
| cp -R "$APP_PATH" "$STAGING_DIR/" | |
| ln -s /Applications "$STAGING_DIR/Applications" | |
| hdiutil create \ | |
| -volname "MCCompanion" \ | |
| -srcfolder "$STAGING_DIR" \ | |
| -ov \ | |
| -format UDZO \ | |
| "$GITHUB_WORKSPACE/MCCompanion-macos.dmg" | |
| codesign --force --sign - "$GITHUB_WORKSPACE/MCCompanion-macos.dmg" | |
| codesign --verify --strict "$GITHUB_WORKSPACE/MCCompanion-macos.dmg" | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: macos-dmg | |
| path: MCCompanion-macos.dmg | |
| build-linux: | |
| name: Build Linux tarball | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.44.0' | |
| channel: stable | |
| cache: true | |
| - name: Cache pub dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.pub-cache | |
| key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub- | |
| - name: Install Linux dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang cmake libgtk-3-dev libwebkit2gtk-4.1-dev ninja-build pkg-config | |
| - name: Enable Linux desktop | |
| run: flutter config --enable-linux-desktop | |
| - name: Regenerate Linux Flutter files | |
| run: flutter create --platforms=linux --project-name mccompanion . | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Build Linux | |
| run: flutter build linux --release | |
| - name: Archive Linux build | |
| run: tar -C build/linux/x64/release -czf MCCompanion-linux-x64.tar.gz bundle | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: linux-tarball | |
| path: MCCompanion-linux-x64.tar.gz | |
| build-flatpak: | |
| name: Build Flatpak Bundle | |
| needs: [build-linux] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: linux-tarball | |
| path: /tmp/ | |
| - name: Update Flatpak metadata version | |
| shell: bash | |
| run: | | |
| VERSION="$(sed -nE "s/^version: *['\"]?([0-9]+\.[0-9]+\.[0-9]+)(\+[0-9]+)?['\"]?.*/\1/p" pubspec.yaml | head -n1)" | |
| if [ -z "$VERSION" ]; then | |
| echo "Failed to determine version from pubspec.yaml" | |
| exit 1 | |
| fi | |
| RELEASE_DATE="$(date -u +%Y-%m-%d)" | |
| python3 - "$VERSION" "$RELEASE_DATE" <<'PY' | |
| import re | |
| import sys | |
| from pathlib import Path | |
| version = sys.argv[1] | |
| release_date = sys.argv[2] | |
| path = Path("flatpak/net.mccompanion.MCCompanion.metainfo.xml") | |
| text = path.read_text() | |
| text, count = re.subn( | |
| r'(<release\s+version=")[^"]+(")', | |
| rf'\g<1>{version}\g<2>', | |
| text, | |
| count=1, | |
| ) | |
| if count != 1: | |
| raise SystemExit("Could not update Flatpak release version") | |
| text, count = re.subn( | |
| rf'(<release\s+version="{re.escape(version)}"\s+date=")[^"]+(")', | |
| rf'\g<1>{release_date}\g<2>', | |
| text, | |
| count=1, | |
| ) | |
| if count != 1: | |
| raise SystemExit("Could not update Flatpak release date") | |
| path.write_text(text) | |
| print(f"Flatpak metadata updated: {version} ({release_date})") | |
| PY | |
| - name: Install Linux build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y python3-yaml flatpak flatpak-builder | |
| - name: Add Flathub remote | |
| run: | | |
| flatpak remote-add --if-not-exists --user flathub \ | |
| https://dl.flathub.org/repo/flathub.flatpakrepo | |
| - name: Install Flatpak runtime and SDK | |
| run: | | |
| flatpak install --user --noninteractive flathub \ | |
| org.freedesktop.Platform//24.08 \ | |
| org.freedesktop.Sdk//24.08 | |
| - name: Prepare Flatpak sources | |
| run: | | |
| python3 - <<EOF | |
| import yaml | |
| with open('flatpak/net.mccompanion.MCCompanion.yml') as f: | |
| data = yaml.safe_load(f) | |
| for mod in data['modules']: | |
| if mod.get('name') == 'MCCompanion': # <-- Only target MCCompanion | |
| for src in mod.get('sources', []): | |
| if src.get('type') == 'archive': | |
| src.pop('url', None) | |
| src.pop('sha256', None) | |
| src.pop('x-checker-data', None) | |
| src['path'] = '/tmp/MCCompanion-linux-x64.tar.gz' | |
| with open('/tmp/net.mccompanion.MCCompanion.yml', 'w') as f: | |
| yaml.dump(data, f, default_flow_style=False) | |
| EOF | |
| - name: Build Flatpak bundle | |
| run: | | |
| flatpak-builder \ | |
| --user \ | |
| --install-deps-from=flathub \ | |
| --force-clean \ | |
| --repo=/tmp/flatpak-repo \ | |
| /tmp/flatpak-build \ | |
| /tmp/net.mccompanion.MCCompanion.yml | |
| flatpak build-bundle \ | |
| /tmp/flatpak-repo \ | |
| MCCompanion-linux.flatpak \ | |
| net.mccompanion.MCCompanion | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: linux-flatpak | |
| path: MCCompanion-linux.flatpak | |
| build-snap: | |
| name: Build Snap Package | |
| needs: [build-linux] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: linux-tarball | |
| path: /tmp/ | |
| - name: Update Snap version from pubspec | |
| shell: bash | |
| run: | | |
| VERSION="$(sed -nE "s/^version: *['\"]?([0-9]+\.[0-9]+\.[0-9]+)(\+[0-9]+)?['\"]?.*/\1/p" pubspec.yaml | head -n1)" | |
| if [ -z "$VERSION" ]; then | |
| echo "Failed to determine version from pubspec.yaml" | |
| exit 1 | |
| fi | |
| python3 - "$VERSION" <<'PY' | |
| import re | |
| import sys | |
| from pathlib import Path | |
| version = sys.argv[1] | |
| path = Path("snap/snapcraft.yaml") | |
| text = path.read_text() | |
| text, count = re.subn( | |
| r"(?m)^version:\s*['\"][^'\"]+['\"]\s*$", | |
| f"version: '{version}'", | |
| text, | |
| count=1, | |
| ) | |
| if count != 1: | |
| raise SystemExit("Could not update version in snap/snapcraft.yaml") | |
| path.write_text(text) | |
| print(f"Snap version updated: {version}") | |
| PY | |
| - name: Patch snapcraft source to local archive | |
| run: | | |
| python3 - <<EOF | |
| import yaml | |
| with open('snap/snapcraft.yaml') as f: | |
| data = yaml.safe_load(f) | |
| data['parts']['mccompanion']['source'] = '/tmp/MCCompanion-linux-x64.tar.gz' | |
| data['parts']['mccompanion']['source-type'] = 'tar' | |
| with open('snap/snapcraft.yaml', 'w') as f: | |
| yaml.dump(data, f, default_flow_style=False) | |
| EOF | |
| - name: Install snapcraft | |
| run: sudo snap install snapcraft --classic | |
| - name: Build snap | |
| run: sudo snapcraft pack --destructive-mode | |
| - name: Rename snap artifact | |
| run: mv *.snap MCCompanion-linux.snap | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: linux-snap | |
| path: MCCompanion-linux.snap | |
| release: | |
| name: Create or Update dev Release | |
| needs: [build-android, build-windows, build-macos, build-linux, build-flatpak, build-snap] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: android-apk | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: windows-zip | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: windows-msix | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: macos-dmg | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: linux-tarball | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: linux-flatpak | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: linux-snap | |
| path: artifacts/ | |
| - name: Rename Android APK | |
| run: mv artifacts/app-release.apk artifacts/MCCompanion-android.apk | |
| - name: Create or update dev release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: dev | |
| name: Development Build | |
| prerelease: true | |
| body: | | |
| Automated development build from commit ${{ github.sha }} on branch `${{ github.ref_name }}`. | |
| This is a development build. If you don't know what you are doing, please don't install it. | |
| Warning: Google/Apple authentication won't work with dev builds. | |
| files: | | |
| artifacts/MCCompanion-android.apk | |
| artifacts/MCCompanion-windows.zip | |
| artifacts/MCCompanion-macos.dmg | |
| artifacts/MCCompanion-linux-x64.tar.gz | |
| artifacts/MCCompanion.msix | |
| artifacts/MCCompanion-linux.flatpak | |
| artifacts/MCCompanion-linux.snap | |
| notify-discord: | |
| name: Notify Discord | |
| if: ${{ always() }} | |
| needs: [build-android, build-windows, build-macos, build-linux, build-flatpak, build-snap, release] | |
| runs-on: ubuntu-latest | |
| permissions: {} | |
| steps: | |
| - name: Send build status embed | |
| env: | |
| DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| ANDROID_RESULT: ${{ needs.build-android.result }} | |
| WINDOWS_RESULT: ${{ needs.build-windows.result }} | |
| MACOS_RESULT: ${{ needs.build-macos.result }} | |
| LINUX_RESULT: ${{ needs.build-linux.result }} | |
| FLATPAK_RESULT: ${{ needs.build-flatpak.result }} | |
| SNAP_RESULT: ${{ needs.build-snap.result }} | |
| RELEASE_RESULT: ${{ needs.release.result }} | |
| REPOSITORY: ${{ github.repository }} | |
| BRANCH: ${{ github.ref_name }} | |
| ACTOR: ${{ github.actor }} | |
| SHA: ${{ github.sha }} | |
| COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
| RUN_ID: ${{ github.run_id }} | |
| SERVER_URL: ${{ github.server_url }} | |
| RELEASES_URL: ${{ github.server_url }}/${{ github.repository }}/releases/tag/dev | |
| run: | | |
| if [ -z "$DISCORD_WEBHOOK_URL" ]; then | |
| echo "DISCORD_WEBHOOK_URL is not configured. Skipping Discord notification." | |
| exit 0 | |
| fi | |
| OVERALL_STATUS="✅ Build Succeeded" | |
| EMBED_COLOR=5763719 | |
| if [ "$ANDROID_RESULT" != "success" ] || [ "$WINDOWS_RESULT" != "success" ] || [ "$MACOS_RESULT" != "success" ] || [ "$LINUX_RESULT" != "success" ] || [ "$FLATPAK_RESULT" != "success" ] || [ "$SNAP_RESULT" != "success" ] || [ "$RELEASE_RESULT" != "success" ]; then | |
| OVERALL_STATUS="❌ Build Failed" | |
| EMBED_COLOR=15548997 | |
| fi | |
| RUN_URL="$SERVER_URL/$REPOSITORY/actions/runs/$RUN_ID" | |
| COMMIT_URL="$SERVER_URL/$REPOSITORY/commit/$SHA" | |
| COMMIT_SUBJECT="$(printf '%s' "$COMMIT_MESSAGE" | head -n 1)" | |
| PAYLOAD="$(jq -n \ | |
| --arg overallStatus "$OVERALL_STATUS" \ | |
| --arg repository "$REPOSITORY" \ | |
| --arg branch "$BRANCH" \ | |
| --arg actor "$ACTOR" \ | |
| --arg runUrl "$RUN_URL" \ | |
| --arg commitUrl "$COMMIT_URL" \ | |
| --arg sha "$SHA" \ | |
| --arg commitSubject "$COMMIT_SUBJECT" \ | |
| --arg android "$ANDROID_RESULT" \ | |
| --arg windows "$WINDOWS_RESULT" \ | |
| --arg macos "$MACOS_RESULT" \ | |
| --arg linux "$LINUX_RESULT" \ | |
| --arg flatpak "$FLATPAK_RESULT" \ | |
| --arg snap "$SNAP_RESULT" \ | |
| --arg release "$RELEASE_RESULT" \ | |
| --arg releasesUrl "$RELEASES_URL" \ | |
| --argjson color "$EMBED_COLOR" \ | |
| '{ | |
| username: "GitHub Actions", | |
| avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", | |
| embeds: [ | |
| { | |
| title: $overallStatus, | |
| color: $color, | |
| description: ("**Repository:** `" + $repository + "`\n**Branch:** `" + $branch + "`\n**Triggered by:** `" + $actor + "`"), | |
| author: { | |
| name: "GitHub", | |
| icon_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" | |
| }, | |
| fields: [ | |
| { name: "Android", value: $android, inline: true }, | |
| { name: "Windows", value: $windows, inline: true }, | |
| { name: "macOS", value: $macos, inline: true }, | |
| { name: "Linux", value: $linux, inline: true }, | |
| { name: "Flatpak", value: $flatpak, inline: true }, | |
| { name: "Snap", value: $snap, inline: true }, | |
| { name: "Release", value: $release, inline: true }, | |
| { name: "Commit", value: ("[" + ($sha | .[0:7]) + "](" + $commitUrl + ")" + (if $commitSubject != "" then " " + $commitSubject else "" end)), inline: false }, | |
| { name: "Releases Page", value: ("[View Releases](" + $releasesUrl + ")"), inline: false } | |
| ], | |
| url: $runUrl, | |
| timestamp: now | todateiso8601 | |
| } | |
| ] | |
| }')" | |
| RESPONSE_FILE="$(mktemp)" | |
| HTTP_STATUS="$(curl -sS -o "$RESPONSE_FILE" -w "%{http_code}" -H "Content-Type: application/json" -d "$PAYLOAD" "$DISCORD_WEBHOOK_URL" || true)" | |
| if [ "${HTTP_STATUS:-000}" -lt 200 ] || [ "${HTTP_STATUS:-000}" -ge 300 ]; then | |
| echo "Failed to send Discord notification. HTTP status: ${HTTP_STATUS:-000}" | |
| echo "Response body:" | |
| cat "$RESPONSE_FILE" | |
| exit 1 | |
| fi | |
| rm -f "$RESPONSE_FILE" | |
| release-beta: | |
| name: Create or Update beta Release | |
| needs: [build-android, build-windows, build-macos, build-linux, build-flatpak, build-snap] | |
| if: ${{ needs.build-android.result == 'success' && needs.build-windows.result == 'success' && needs.build-macos.result == 'success' && needs.build-linux.result == 'success' && needs.build-flatpak.result == 'success' && needs.build-snap.result == 'success' && startsWith(github.event.head_commit.message, '[beta]') }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: android-apk | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: windows-zip | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: windows-msix | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: macos-dmg | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: linux-tarball | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: linux-flatpak | |
| path: artifacts/ | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: linux-snap | |
| path: artifacts/ | |
| - name: Rename Android APK | |
| run: mv artifacts/app-release.apk artifacts/MCCompanion-android.apk | |
| - name: Create or update beta release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: beta | |
| target_commitish: ${{ github.sha }} | |
| name: Beta Build | |
| prerelease: true | |
| body: | | |
| Automated beta build from commit ${{ github.sha }} on branch `${{ github.ref_name }}`. | |
| This is a beta build intended for testing before wider release. | |
| Warning: Google/Apple authentication won't work with beta builds. | |
| files: | | |
| artifacts/MCCompanion-android.apk | |
| artifacts/MCCompanion-windows.zip | |
| artifacts/MCCompanion-macos.dmg | |
| artifacts/MCCompanion-linux-x64.tar.gz | |
| artifacts/MCCompanion.msix | |
| artifacts/MCCompanion-linux.flatpak | |
| artifacts/MCCompanion-linux.snap | |
| publish-snap: | |
| name: Publish Dev Build to Snap Store | |
| needs: [build-snap, release] | |
| if: ${{ needs.build-snap.result == 'success' && needs.release.result == 'success' }} | |
| runs-on: ubuntu-latest | |
| permissions: {} | |
| steps: | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| name: linux-snap | |
| path: artifacts/ | |
| - name: Upload snap to Snap Store (edge channel) | |
| env: | |
| SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} | |
| run: | | |
| if [ -z "$SNAPCRAFT_STORE_CREDENTIALS" ]; then | |
| echo "SNAPCRAFT_STORE_CREDENTIALS secret is not set. Skipping Snap Store upload." | |
| exit 0 | |
| fi | |
| sudo snap install snapcraft --classic | |
| snapcraft upload artifacts/MCCompanion-linux.snap --release=edge | |
| notify-discord-beta: | |
| name: Notify Discord Beta Release | |
| needs: [release-beta] | |
| if: ${{ needs.release-beta.result == 'success' }} | |
| runs-on: ubuntu-latest | |
| permissions: {} | |
| steps: | |
| - name: Send beta release embed | |
| env: | |
| DISCORD_BETA_WEBHOOK_URL: ${{ secrets.DISCORD_BETA_WEBHOOK_URL }} | |
| REPOSITORY: ${{ github.repository }} | |
| ACTOR: ${{ github.actor }} | |
| SHA: ${{ github.sha }} | |
| COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
| RUN_ID: ${{ github.run_id }} | |
| SERVER_URL: ${{ github.server_url }} | |
| BETA_RELEASE_URL: ${{ github.server_url }}/${{ github.repository }}/releases/tag/beta | |
| run: | | |
| if [ -z "$DISCORD_BETA_WEBHOOK_URL" ]; then | |
| echo "DISCORD_BETA_WEBHOOK_URL is not configured. Skipping Discord beta notification." | |
| exit 0 | |
| fi | |
| ROLE_ID="1485783465365344316" | |
| RUN_URL="$SERVER_URL/$REPOSITORY/actions/runs/$RUN_ID" | |
| COMMIT_URL="$SERVER_URL/$REPOSITORY/commit/$SHA" | |
| COMMIT_SUBJECT="$(printf '%s' "$COMMIT_MESSAGE" | head -n 1)" | |
| PAYLOAD="$(jq -n \ | |
| --arg roleId "$ROLE_ID" \ | |
| --arg betaReleaseUrl "$BETA_RELEASE_URL" \ | |
| --arg commitUrl "$COMMIT_URL" \ | |
| --arg sha "$SHA" \ | |
| --arg commitSubject "$COMMIT_SUBJECT" \ | |
| --arg runUrl "$RUN_URL" \ | |
| --arg actor "$ACTOR" \ | |
| '{ | |
| content: ("<@&" + $roleId + ">"), | |
| allowed_mentions: { | |
| roles: [$roleId] | |
| }, | |
| username: "GitHub Actions", | |
| avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", | |
| embeds: [ | |
| { | |
| title: "🚀 New Beta Release Available", | |
| url: $betaReleaseUrl, | |
| color: 5793266, | |
| description: ("Hello, <@&" + $roleId + ">, we have a new beta release ready. Check it out on our [beta release](" + $betaReleaseUrl + ")."), | |
| author: { | |
| name: "MCCompanion Beta Releases", | |
| icon_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" | |
| }, | |
| fields: [ | |
| { name: "Commit", value: ("[" + ($sha | .[0:7]) + "](" + $commitUrl + ")" + (if $commitSubject != "" then " " + $commitSubject else "" end)), inline: false }, | |
| { name: "Platforms", value: "Android • Windows • macOS • Linux", inline: true }, | |
| { name: "Download links", value: ("[Beta release](" + $betaReleaseUrl + ")"), inline: true }, | |
| { name: "Triggered by", value: $actor, inline: true }, | |
| { name: "Workflow", value: ("[View run](" + $runUrl + ")"), inline: true } | |
| ], | |
| footer: { | |
| text: "MCCompanion beta release" | |
| }, | |
| timestamp: now | todateiso8601 | |
| } | |
| ] | |
| }')" | |
| RESPONSE_FILE="$(mktemp)" | |
| HTTP_STATUS="$(curl -sS -o "$RESPONSE_FILE" -w "%{http_code}" -H "Content-Type: application/json" -d "$PAYLOAD" "$DISCORD_BETA_WEBHOOK_URL")" | |
| CURL_EXIT_CODE=$? | |
| if [ "$CURL_EXIT_CODE" -ne 0 ]; then | |
| echo "Failed to send Discord beta release notification with curl exit code: $CURL_EXIT_CODE" | |
| exit "$CURL_EXIT_CODE" | |
| fi | |
| if [ "${HTTP_STATUS:-000}" -lt 200 ] || [ "${HTTP_STATUS:-000}" -ge 300 ]; then | |
| echo "Failed to send Discord beta release notification. HTTP status: ${HTTP_STATUS:-000}" | |
| echo "Response body:" | |
| cat "$RESPONSE_FILE" | |
| exit 1 | |
| fi | |
| rm -f "$RESPONSE_FILE" |