Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(build): refresh #1521

Draft
wants to merge 16 commits into
base: dev
Choose a base branch
from
Draft
61 changes: 37 additions & 24 deletions .github/workflows/pr-build.yml
Expand Up @@ -3,6 +3,7 @@ name: PR Build
on:
workflow_dispatch:
inputs:

# Flutter
flutter-branch:
description: Flutter branch
Expand All @@ -17,21 +18,29 @@ on:
description: Cache
type: boolean
default: true

# Application configuration
app-flavour:
app-flavor:
description: App flavour
default: 'release'
type: choice
options:
- release
- debug
- profile

# Pull Request
pr-number:
description: PR number (No hashtag)
description: PR number
required: true

run-name: "Build PR ${{ inputs.pr-number }}"

# Additional
flutter-build-arguments:
description: Flutter build arguments
additional-description:
description: What's the purpose of triggering?

run-name: "Build PR ${{ inputs.pr-number }} ${{ inputs.additional-description }}"

jobs:
build:
Expand All @@ -41,7 +50,7 @@ jobs:
contents: read
pull-requests: write
steps:
- name: Setup
- name: Setup the PR's repository
env:
GH_TOKEN: ${{ github.token }}
run: |
Expand All @@ -50,16 +59,15 @@ jobs:
gh repo set-default ${{ github.repository }}
gh pr checkout ${{ inputs.pr-number }}

echo "DATETIME=$( TZ='UTC+0' date --rfc-email )" >> $GITHUB_ENV
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Checkout
- name: Checkout the repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'zulu'
Expand All @@ -76,23 +84,37 @@ jobs:

- name: Generate files with Builder
run: dart run build_runner build --delete-conflicting-outputs

- name: Analyze Dart code
uses: zgosalvez/github-actions-analyze-dart@v3

- name: Build with Flutter
continue-on-error: true
id: flutter-build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
flutter build apk --${{ inputs.app-flavour }};
flutter build apk --${{ inputs.app-flavor }} ${{ inputs.flutter-build-arguments }}

- name: Prepare to comment
run: |
if [[ "${{ steps.flutter-build.outcome }}" == "success" ]]; then
echo "MESSAGE=✅ ReVanced Manager ${{ env.COMMIT_HASH }} build succeeded." >> $GITHUB_ENV
echo "STATUS_MESSAGE=✅ ReVanced Manager ${{ env.COMMIT_HASH }} build succeeded." >> $GITHUB_ENV
else
echo "MESSAGE=🚫 ReVanced Manager ${{ env.COMMIT_HASH }} build failed." >> $GITHUB_ENV
echo "STATUS_MESSAGE=🚫 ReVanced Manager ${{ env.COMMIT_HASH }} build failed." >> $GITHUB_ENV
fi
if [ -n "{{ inputs.flutter-build-arguments }}" ]; then
echo "COMPILE_ARGUMENT_MESSAGE=- Compile arguments: ${{ inputs.flutter-build-arguments }}" >> $GITHUB_ENV
fi

- name: Upload build
uses: actions/upload-artifact@v3
with:
name: revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavor }})-${{ inputs.flutter-branch }}
path: |
build/app/outputs/flutter-apk/app-${{ inputs.app-flavor }}.apk
build/app/outputs/flutter-apk/app-${{ inputs.app-flavor }}.apk.sha1

- name: "Comment to Pull Request #${{ inputs.pr-number }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this step comment as @revanced-bot?

Copy link
Member Author

@validcube validcube Dec 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this step comment as @revanced-bot?

This was mentioned in the initial pull request for ci(build), this suggestion depends on the repository manager which is out of my limit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The repository manager being who? @oSumAtrIX can you look into this?

uses: thollander/actions-comment-pull-request@v2
with:
Expand All @@ -102,20 +124,11 @@ jobs:
message: |
## ⚒️ ReVanced PR Build workflow

${{ env.MESSAGE }}
${{ env.STATUS_MESSAGE }}

You can see more details in run [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})!
Checkout the Dart static analyze check or download the artifact at [job summary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).

### ⚙️ Overview
- App flavor: ${{ inputs.app-flavour }}
- App flavor: ${{ inputs.app-flavor }}
- Branch: ${{ inputs.flutter-branch }}
- Start time: ${{ env.DATETIME }}

- name: Upload build
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavour }})-${{ inputs.flutter-branch }}
path: |
build/app/outputs/flutter-apk/app-${{ inputs.app-flavour }}.apk
build/app/outputs/flutter-apk/app-${{ inputs.app-flavour }}.apk.sha1
${{ env.COMPILE_ARGUMENT_MESSAGE }}