Refactoring/debug section (#83) #20
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: "Debug Build APK" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| check-skip-conditions: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| skip-build: ${{ steps.check-labels.outputs.skip_build }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check PR labels | |
| id: check-labels | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const { execSync } = require('child_process'); | |
| // Get the last commit message | |
| const lastCommitMsg = execSync('git log -1 --pretty=format:%s').toString().trim(); | |
| console.log(`Last commit message: ${lastCommitMsg}`); | |
| // Check if this is a PR merge commit | |
| const prMergeRegex = /Merge pull request #(\d+) from/; | |
| const prMatch = lastCommitMsg.match(prMergeRegex); | |
| if (!prMatch) { | |
| console.log('Not a PR merge commit, proceeding with build'); | |
| core.setOutput('skip_build', 'false'); | |
| return; | |
| } | |
| const prNumber = prMatch[1]; | |
| console.log(`PR number: ${prNumber}`); | |
| // Get PR details from GitHub API | |
| try { | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: parseInt(prNumber) | |
| }); | |
| const labels = pr.labels || []; | |
| const skipLabels = ['docs-only', 'no-build']; | |
| const shouldSkip = labels.some(label => skipLabels.includes(label.name)); | |
| console.log(`Labels: ${labels.map(l => l.name).join(', ')}`); | |
| console.log(`Should skip build: ${shouldSkip}`); | |
| core.setOutput('skip_build', shouldSkip.toString()); | |
| } catch (error) { | |
| console.error(`Error fetching PR #${prNumber}: ${error.message}`); | |
| core.setOutput('skip_build', 'false'); | |
| } | |
| result-encoding: string | |
| build-debug: | |
| name: "Build Debug APK" | |
| needs: check-skip-conditions | |
| if: ${{ needs.check-skip-conditions.outputs.skip-build == 'false' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "Checkout repository" | |
| uses: actions/checkout@v4 | |
| - name: "Set up Java" | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "oracle" | |
| java-version: "22" | |
| - name: "Set up Gradle" | |
| uses: gradle/actions/setup-gradle@v3 | |
| with: | |
| gradle-version: wrapper | |
| - name: "Set up Flutter" | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| flutter-version-file: pubspec.yaml | |
| cache: true | |
| - name: "Setup Ruby" | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.1' | |
| working-directory: 'android' | |
| bundler-cache: true | |
| - name: "Run Fastlane Debug Build" | |
| id: fastlane | |
| uses: maierj/fastlane-action@v3.1.0 | |
| with: | |
| lane: build_debug_with_release | |
| subdirectory: android | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| - name: "Upload Debug APK" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: movetopia-debug | |
| path: android/fastlane/build/outputs/movetopia-debug.apk | |
| - name: "Create release tag" | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| generateReleaseNotes: true | |
| prerelease: true | |
| tag: ${{ env.VERSION_NAME }} | |
| name: ${{ env.VERSION_NAME }} | |
| artifacts: "android/fastlane/build/outputs/movetopia-debug.apk" | |