-
-
Notifications
You must be signed in to change notification settings - Fork 776
142 lines (119 loc) Β· 4.62 KB
/
pr-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: PR Build
on:
workflow_dispatch:
inputs:
# Flutter
flutter-branch:
description: Flutter branch
type: choice
default: 'stable'
options:
- stable
- beta
- dev
- master
flutter-cache:
description: Cache
type: boolean
default: true
# Application configuration
app-flavour:
description: App flavour
default: 'release'
type: choice
options:
- release
- debug
- profile
# Pull Request
pr-number:
description: PR number (No hashtag)
required: true
# Additional
flutter-build-arguments:
description: Flutter build arguments
run-name: "Build PR ${{ inputs.pr-number }}"
jobs:
build:
name: Build the application
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Setup the PR's repository
env:
GH_TOKEN: ${{ github.token }}
run: |
gh repo clone ${{ github.repository }}
cd revanced-manager
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 the repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
cache: gradle
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: ${{ inputs.flutter-branch }}
cache: ${{ inputs.flutter-cache }}
- name: Install Flutter dependencies
run: flutter pub get
- name: Generate files with Builder
run: dart run build_runner build --delete-conflicting-outputs
- name: Dart static analysis
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 }} ${{ 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
else
echo "MESSAGE=π« ReVanced Manager ${{ env.COMMIT_HASH }} build failed." >> $GITHUB_ENV
fi
- name: Upload build
uses: actions/upload-artifact@v3
with:
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
- name: Get artifact URL
run: |
sudo apt install jq
ARTIFACT_URL=$(curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-s "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts" | \
jq -r ".artifacts[] | select(.name==\"revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavour }})-${{ inputs.flutter-branch }}\") | .archive_download_url")
echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV
- name: "Comment to Pull Request #${{ inputs.pr-number }}"
uses: thollander/actions-comment-pull-request@v2
with:
GITHUB_TOKEN: ${{ github.token }}
pr_number: ${{ inputs.pr-number }}
mode: recreate
message: |
## βοΈ ReVanced PR Build workflow
${{ env.MESSAGE }}
Checkout the Dart static analyze check at [job summary](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
Directly download the [application artifact](${{ env.ARTIFACT_URL }}) here.
### βοΈ Overview
- App flavor: ${{ inputs.app-flavour }}
- Branch: ${{ inputs.flutter-branch }}
- Compile arguments: ${{ inputs.flutter-build-arguments }}
- Start time: ${{ env.DATETIME }}