diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 1c96ae5..c026ce8 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -6,6 +6,11 @@ on: paths-ignore: - '**.md' - 'fastlane/**' + workflow_dispatch: + inputs: + pr_number: + description: 'PR Number' + required: true # We need permission to write comments on the PR permissions: @@ -19,6 +24,15 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 + - name: Determine PR Number + id: pr_context + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + echo "PR_NUMBER=${{ github.event.number }}" >> $GITHUB_ENV + else + echo "PR_NUMBER=${{ inputs.pr_number }}" >> $GITHUB_ENV + fi + - name: Set up JDK 17 uses: actions/setup-java@v4 with: @@ -32,11 +46,13 @@ jobs: # 1. FIND OR CREATE THE INITIAL COMMENT - name: Post "Building" Comment uses: actions/github-script@v7 + env: + PR_NUMBER: ${{ env.PR_NUMBER }} with: script: | const marker = ''; const { owner, repo } = context.repo; - const issue_number = context.issue.number; + const issue_number = parseInt(process.env.PR_NUMBER); // Find existing comment const comments = await github.rest.issues.listComments({ @@ -46,10 +62,9 @@ jobs: const body = `${marker} ### 🔨 Building Debug APK... - _Compiling latest changes... please wait._
- Current Status + View Status Building on GitHub Actions...
`; @@ -67,7 +82,9 @@ jobs: # We pipe output to a file (build.log) AND to console (tee) so we can read it later - name: Build Debug APK id: build_apk + shell: bash run: | + set -o pipefail ./gradlew assembleDebug --stacktrace | tee build.log # 3. UPLOAD THE APK ARTIFACT @@ -75,7 +92,7 @@ jobs: if: success() uses: actions/upload-artifact@v4 with: - name: compressor-debug-pr-${{ github.event.number }} + name: compressor-debug-pr-${{ env.PR_NUMBER }} path: app/build/outputs/apk/debug/app-debug.apk retention-days: 5 @@ -99,11 +116,12 @@ jobs: LOGS: ${{ steps.process_logs.outputs.LOG_CONTENT }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} STATUS: ${{ job.status }} + PR_NUMBER: ${{ env.PR_NUMBER }} with: script: | const marker = ''; const { owner, repo } = context.repo; - const issue_number = context.issue.number; + const issue_number = parseInt(process.env.PR_NUMBER); const logs = process.env.LOGS; const runUrl = process.env.RUN_URL; const status = process.env.STATUS; @@ -114,16 +132,15 @@ jobs: }); const botComment = comments.data.find(c => c.body.includes(marker)); - let title = status === 'success' ? '✅ Build Successful' : '❌ Build Failed'; + let title = status === 'success' ? '## ✅ Build Successful' : '## ❌ Build Failed'; let downloadSection = status === 'success' - ? `### 📥 [Download Debug APK](${runUrl}) - **⚠️ WARNING:** This is a **DEBUG** build. It is signed with a debug key. - - Do not install this unless you are testing this PR. - - You will need to uninstall Release version first. - - To download: Click the link above, scroll down to **Artifacts**. - ` - : `### ⛔ Build Failed - The compiler encountered errors. See logs below.`; + ? \`**Debug APK Ready** + + [Download from Artifacts](${runUrl}) + + > **Note:** You may need to uninstall the existing version before installing this debug build. + \` + : \`**The build encountered errors.** See the logs below for details.\`; const body = `${marker} ${title} @@ -131,14 +148,12 @@ jobs: ${downloadSection}
- 📝 Build Logs (Last 150 lines) + Build Logs \`\`\`text ${logs} \`\`\`
- - _Updated: ${new Date().toISOString()}_ `; if (botComment) { diff --git a/.github/workflows/pr-commands.yml b/.github/workflows/pr-commands.yml new file mode 100644 index 0000000..0bd27f4 --- /dev/null +++ b/.github/workflows/pr-commands.yml @@ -0,0 +1,67 @@ +name: PR Commands + +on: + issue_comment: + types: [created] + +permissions: + pull-requests: write + issues: write + actions: write + contents: read + +jobs: + command-handler: + runs-on: ubuntu-latest + if: github.event.issue.pull_request && contains(github.event.comment.body, '/rebuild') + steps: + - name: Check Permission and Trigger Build + uses: actions/github-script@v7 + with: + script: | + const commenter = context.payload.comment.user.login; + const prCreator = context.payload.issue.user.login; + const owner = context.repo.owner; + const body = context.payload.comment.body; + + console.log(`User: ${commenter}, PR Creator: ${prCreator}, Owner: ${owner}`); + + // 1. Authorization Check + if (commenter !== prCreator && commenter !== owner) { + console.log(`❌ User ${commenter} is not authorized.`); + await github.rest.reactions.createForIssueComment({ + owner, repo: context.repo.repo, + comment_id: context.payload.comment.id, + content: '-1' + }); + return; + } + + console.log('✅ User is authorized.'); + + // 2. React to the comment (Thumbs up) + await github.rest.reactions.createForIssueComment({ + owner, repo: context.repo.repo, + comment_id: context.payload.comment.id, + content: '+1' + }); + + // 3. Get PR details to find the branch + const { data: pr } = await github.rest.pulls.get({ + owner, + repo: context.repo.repo, + pull_number: context.issue.number + }); + + console.log(`Triggering rebuild for branch: ${pr.head.ref}`); + + // 4. Trigger the main android.yml workflow + await github.rest.actions.createWorkflowDispatch({ + owner, + repo: context.repo.repo, + workflow_id: 'android.yml', + ref: pr.head.ref, // IMPORTANT: Run on the PR's branch + inputs: { + pr_number: context.issue.number.toString() + } + }); diff --git a/README.md b/README.md index ef2e2da..c8e85c3 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,18 @@ Lightning fast, ad free, super lightweight native video compressor for Android ( -[![RB Status](https://shields.rbtlog.dev/simple/compress.joshattic.us?style=for-the-badge)](https://shields.rbtlog.dev/compress.joshattic.us) ![IzzyOnDroid Version](https://img.shields.io/endpoint?url=https://apt.izzysoft.de/fdroid/api/v1/shield/compress.joshattic.us&label=IzzyOnDroid%20Version&style=for-the-badge) [![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/JoshAtticus/Compressor/total?style=for-the-badge&label=GitHub%20Downloads&v=2)](https://github.com/JoshAtticus/Compressor/releases) ![Kotlin](https://img.shields.io/badge/kotlin-%237F52FF.svg?style=for-the-badge&logo=kotlin&logoColor=white) ![Android](https://img.shields.io/badge/Android-3DDC84?style=for-the-badge&logo=android&logoColor=white) ![License](https://img.shields.io/github/license/JoshAtticus/Compressor?style=for-the-badge) ![Stars](https://img.shields.io/github/stars/JoshAtticus/Compressor?style=for-the-badge) ![Forks](https://img.shields.io/github/forks/JoshAtticus/Compressor?style=for-the-badge) +![Kotlin](https://img.shields.io/badge/kotlin-%237F52FF.svg?style=for-the-badge&logo=kotlin&logoColor=white) ![Android](https://img.shields.io/badge/Android-3DDC84?style=for-the-badge&logo=android&logoColor=white) ![License](https://img.shields.io/github/license/JoshAtticus/Compressor?style=for-the-badge) + +**Stats** + +[![RB Status](https://shields.rbtlog.dev/simple/compress.joshattic.us?style=for-the-badge)](https://shields.rbtlog.dev/compress.joshattic.us) ![IzzyOnDroid Version](https://img.shields.io/endpoint?url=https://apt.izzysoft.de/fdroid/api/v1/shield/compress.joshattic.us&label=IzzyOnDroid%20Version&style=for-the-badge) ![Stars](https://img.shields.io/github/stars/JoshAtticus/Compressor?style=for-the-badge) ![Forks](https://img.shields.io/github/forks/JoshAtticus/Compressor?style=for-the-badge) + +**Downloads** + +[![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/JoshAtticus/Compressor/total?style=for-the-badge&label=GitHub%20Downloads&v=2)](https://github.com/JoshAtticus/Compressor/releases) [![IzzyOnDroid Downloads (This year)](https://img.shields.io/badge/dynamic/json?url=https://dlstats.izzyondroid.org/iod-stats-collector/stats/basic/yearly/rolling.json&query=$.['compress.joshattic.us']&label=IzzyOnDroid%20yearly%20downloads&style=for-the-badge)](https://apt.izzysoft.de/packages/compress.joshattic.us) [![Google Play Downloads](https://img.shields.io/endpoint?color=green&style=for-the-badge&url=https%3A%2F%2Fplay.cuzi.workers.dev%2Fplay%3Fi%3Dcompress.joshattic.us%26gl%3DUS%26hl%3Den%26l%3DGoogle%2520Play%2520Store%2520Downloads%26m%3D%24totalinstalls)](https://play.google.com/store/apps/details?id=compress.joshattic.us) + +### Yes, reproducible builds have failed, I'm sorry +I'm not going to push blame onto anybody else, this is completely my fault. I've worked really hard on Compressor over the past month, and it's starting to burn me out. I've been trying to fix user issues within 24-48 hours, and in doing so, have been pushing updates very frequently. You may have noticed I've already started releasing and committing less frequently. If I don't respond to your issue instantly, please don't take it personally, I have a life too, I work on Compressor completely for free, and thank you so much for using Compressor :) Do you like Compressor? Consider supporting development by [buying me a coffee](https://www.buymeacoffee.com/joshatticus) ☕️