name: Auto build and pre-release on: workflow_dispatch: push: branches: [ "stable" ] env: BUILD_CONFIGURATION: Release permissions: contents: write jobs: build: strategy: matrix: include: - platform: windows platform_arch: x64 os: windows-latest name: "Windows-x64" - platform: windows platform_arch: x86 os: windows-latest name: "Windows-x86" - platform: android os: ubuntu-latest name: "Android" - platform: linux os: ubuntu-latest name: "Linux-x64" runs-on: ${{ matrix.os }} name: Build ${{ matrix.name }} steps: - name: Checkout uses: actions/checkout@v6 with: submodules: recursive - name: Configure CMake if: matrix.platform == 'windows' working-directory: ${{env.GITHUB_WORKSPACE}} run: cmake -S . -B build -A ${{ matrix.platform_arch == 'x86' && 'Win32' || 'x64' }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_CONFIGURATION }} -DBUILD_EXECUTABLE=ON - name: Build with CMake if: matrix.platform == 'windows' working-directory: ${{env.GITHUB_WORKSPACE}} run: cmake --build build --config ${{ env.BUILD_CONFIGURATION }} --parallel - name: Upload PDBs to Sentry if: matrix.platform == 'windows' env: SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }} SENTRY_ORG: "t5-j7" SENTRY_PROJECT: "native" COMMIT_HASH: ${{ github.sha }} RELEASE_TAG: "CasioEmuMsvc@${{ github.sha }}" working-directory: build/CasioEmuMsvc/${{ env.BUILD_CONFIGURATION }} run: | $sentry_cli = "${{ github.workspace }}\CasioEmuMsvc\sentry-cli.exe" & $sentry_cli debug-files upload -o $env:SENTRY_ORG -p $env:SENTRY_PROJECT . - name: Upload ${{ matrix.platform_arch }} Build Artifact if: matrix.platform == 'windows' uses: actions/upload-artifact@v7 with: name: Release-${{ matrix.platform_arch }} path: build/CasioEmuMsvc/${{ env.BUILD_CONFIGURATION }} if-no-files-found: error - name: Set up JDK 21 if: matrix.platform == 'android' uses: actions/setup-java@v5 with: java-version: '21' distribution: 'temurin' cache: gradle - name: Grant execute permission to gradlew if: matrix.platform == 'android' run: chmod +x gradlew - name: Build with Gradle if: matrix.platform == 'android' run: ./gradlew assembleRelease - name: Rename APK if: matrix.platform == 'android' run: | SHORT_HASH=$(git rev-parse --short HEAD) for apk in app/build/outputs/apk/release/*.apk; do if [ -f "$apk" ]; then mv "$apk" "${apk%.apk}-${SHORT_HASH}.apk" fi done - name: Upload Universal APK if: matrix.platform == 'android' uses: actions/upload-artifact@v7 with: path: app/build/outputs/apk/release/*-universal-*.apk archive: false - name: Upload arm64-v8a APK if: matrix.platform == 'android' uses: actions/upload-artifact@v7 with: path: app/build/outputs/apk/release/*-arm64-v8a-*.apk archive: false - name: Upload armeabi-v7a APK if: matrix.platform == 'android' uses: actions/upload-artifact@v7 with: path: app/build/outputs/apk/release/*-armeabi-v7a-*.apk archive: false - name: Grant execute permission to build script if: matrix.platform == 'linux' run: chmod +x build-linux.sh - name: Build for Linux if: matrix.platform == 'linux' run: sudo DEBIAN_FRONTEND=noninteractive ./build-linux.sh -y - name: Upload Linux Build Artifact if: matrix.platform == 'linux' uses: actions/upload-artifact@v7 with: name: Release-Linux-x64 path: | build/CasioEmuMsvc/CasioEmuMsvc build/CasioEmuMsvc/crashpad_handler build/CasioEmuMsvc/locales/ build/CasioEmuMsvc/roms.db if-no-files-found: error release: name: Create Release needs: build runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/stable' steps: - name: Checkout uses: actions/checkout@v6 with: fetch-depth: 0 - name: Download All Artifacts uses: actions/download-artifact@v8 with: path: ./artifacts - name: Generate Release Details id: release_details run: | SHORT_HASH=$(git rev-parse --short HEAD) echo "COMMIT_HASH=$SHORT_HASH" >> $GITHUB_ENV echo "RELEASE_TAG=stable-$(date +'%Y%m%d%H%M%S')-$SHORT_HASH" >> $GITHUB_ENV echo "RELEASE_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV CHANGELOG_CONTENT=$(git log -5 --pretty=format:"- %s (%h)" --abbrev-commit) echo "CHANGELOG<> $GITHUB_ENV echo "$CHANGELOG_CONTENT" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - name: Prepare Release Assets run: | mkdir -p release_assets if ls ./artifacts/**/*.apk 1> /dev/null 2>&1; then find ./artifacts -name "*.apk" -type f -exec cp {} release_assets/ \; fi # Package Windows x86 build if [ -d "./artifacts/Release-x86" ]; then cd "./artifacts/Release-x86" zip -r "../../release_assets/windows-x86-${{ env.COMMIT_HASH }}.zip" . cd ../.. fi # Package Windows x64 build if [ -d "./artifacts/Release-x64" ]; then cd "./artifacts/Release-x64" zip -r "../../release_assets/windows-x64-${{ env.COMMIT_HASH }}.zip" . cd ../.. fi # Package Linux x64 build if [ -d "./artifacts/Release-Linux-x64" ]; then cd "./artifacts/Release-Linux-x64" zip -r "../../release_assets/linux-x64-${{ env.COMMIT_HASH }}.zip" . cd ../.. fi ls -la release_assets/ - name: Create GitHub Release uses: softprops/action-gh-release@v3 with: tag_name: ${{ env.RELEASE_TAG }} name: '🚧 Auto Build ${{ env.RELEASE_TAG }} (Pre-release)' body: | ## ⚠️ Pre-release Auto Build > **Warning**: This is an automated pre-release build for testing purposes. > It may contain bugs and is not recommended for production use. **Build Date:** ${{ env.RELEASE_DATE }} **Commit:** [${{ env.COMMIT_HASH }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) ### Recent Changes ${{ env.CHANGELOG }} ### Notes - This is an automated build from the latest commit on the stable branch - Use at your own risk - this is a development build files: release_assets/* draft: false prerelease: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}