Skip to content

Commit 062f283

Browse files
oSumAtrIXvalidcube
andauthored
ci: Modernize workflows (#2473)
Co-authored-by: Pun Butrach <[email protected]>
1 parent a8a4ffa commit 062f283

File tree

3 files changed

+23
-94
lines changed

3 files changed

+23
-94
lines changed

.github/workflows/build_pull_request.yml

Lines changed: 6 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,18 @@ name: Build pull request
33
on:
44
workflow_dispatch:
55
inputs:
6-
# Select pull request
76
pr-number:
8-
description: PR number (Without hashtag)
7+
description: PR number
98
required: true
10-
# Select app flavor
119
app-flavor:
1210
description: App flavor
13-
default: 'release'
11+
default: release
1412
type: choice
1513
options:
1614
- release
1715
- debug
1816
- profile
1917

20-
# Flutter Configurations,
21-
# it's recommended to be set when you have problem regarding with flutter itself
22-
# For most part you do not need to change this.
23-
24-
# Flutter version to use, note that the version had to exist in whether channel
25-
# to grab
26-
# Try using exact version or particular version on a specific branch instead of "any"
27-
flutter-channel:
28-
description: Flutter channel
29-
default: 'stable'
30-
type: choice
31-
options:
32-
- stable
33-
- beta
34-
- dev
35-
- any
36-
flutter-version:
37-
description: Flutter version
38-
default: '3.29.x'
39-
40-
run-name: "Build pull request ${{ inputs.pr-number }}"
41-
4218
jobs:
4319
build:
4420
name: Build
@@ -62,76 +38,27 @@ jobs:
6238
- name: Set up Flutter
6339
uses: subosito/flutter-action@v2
6440
with:
65-
channel: ${{ inputs.flutter-channel }}
66-
flutter-version: ${{ inputs.flutter-version }}
41+
channel: stable
6742

6843
- name: Get dependencies
69-
continue-on-error: true
7044
run: flutter pub get
7145

7246
- name: Generate translations
73-
continue-on-error: true
7447
run: dart run slang
7548

7649
- name: Generate code files
77-
continue-on-error: true
7850
run: dart run build_runner build --delete-conflicting-outputs
7951

8052
- name: Build
81-
continue-on-error: true
8253
id: flutter-build
8354
run: flutter build apk --${{ inputs.app-flavor }}
8455
env:
8556
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8657

87-
- name: Prepare comment
88-
id: prepare-comment # This should work now?
89-
run: |
90-
echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
91-
if [[ "${{ steps.flutter-build.outcome }}" == "success" ]]; then
92-
MESSAGE="✅ Succeeded build on $COMMIT_HASH."
93-
else
94-
MESSAGE="🚫 Failed build on $COMMIT_HASH."
95-
fi
96-
97-
- name: "Comment on pull request #${{ inputs.pr-number }}"
98-
uses: thollander/actions-comment-pull-request@v3
99-
with:
100-
github-token: ${{ github.token }}
101-
pr-number: ${{ inputs.pr-number }}
102-
mode: recreate
103-
comment-tag: execution
104-
message: |
105-
## ⚒️ Build status
106-
107-
🧪 Workflow triggered by: ${{ github.actor }}
108-
109-
${{ steps.prepare-comment.outputs.MESSAGE }}
110-
111-
Details: [_Job execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**_](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})!
112-
113-
### ⚙️ Workflow Steps
114-
115-
| Step | Status |
116-
| :------------------------ | :------------------------------------------------------- |
117-
| **Get dependencies** | ${{ steps.get-dependencies.outcome || job.status }} |
118-
| **Generate translations** | ${{ steps.generate-translations.outcome || job.status }} |
119-
| **Generate code files** | ${{ steps.generate-code-files.outcome || job.status }} |
120-
| **Build** | ${{ steps.flutter-build.outcome }} |
121-
122-
### ⚙️ Workflow Configuration
123-
124-
| Parameter | Value |
125-
| :--------------- | :--------------------------------------- |
126-
| App flavor | ${{ inputs.app-flavor }} |
127-
| Flutter version | ${{ inputs.flutter-version }} |
128-
| Flutter channel | ${{ inputs.flutter-channel }} |
129-
130-
- name: Upload Artifact
58+
- name: Upload artifacts
13159
if: steps.flutter-build.outcome == 'success'
13260
uses: actions/upload-artifact@v4
13361
with:
134-
name: revanced-manager-(${{ env.COMMIT_HASH }}-${{ inputs.pr-number }}-${{ inputs.app-flavor }}-${{ inputs.flutter-version }})
62+
name: revanced-manager-(${{ env.COMMIT_HASH }}
13563
path: |
136-
build/app/outputs/flutter-apk/app-${{ inputs.app-flavor }}.apk
137-
build/app/outputs/flutter-apk/app-${{ inputs.app-flavor }}.apk.sha1
64+
build/app/outputs/flutter-apk/app-*.apk

.github/workflows/open_pull_request.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ env:
1212
jobs:
1313
pull-request:
1414
name: Open pull request
15+
permissions:
16+
pull-requests: write
1517
runs-on: ubuntu-latest
1618
steps:
1719
- name: Checkout
@@ -25,4 +27,3 @@ jobs:
2527
pr_body: |
2628
This pull request will ${{ env.MESSAGE }}.
2729
pr_draft: true
28-
github_token: ${{ secrets.REPOSITORY_PUSH_ACCESS }}

.github/workflows/release.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,13 @@ on:
66
branches:
77
- main
88
- dev
9-
paths:
10-
- ".github/workflows/release.yml"
11-
- "android/**"
12-
- "assets/**"
13-
- "lib/**"
14-
- "pubspec.yaml"
159

1610
jobs:
1711
release:
1812
name: Release
1913
permissions:
20-
id-token: write
2114
contents: write
15+
id-token: write
2216
attestations: write
2317
runs-on: ubuntu-latest
2418
steps:
@@ -28,7 +22,10 @@ jobs:
2822
fetch-depth: 0
2923

3024
- name: Setup Java
31-
run: echo "JAVA_HOME=$JAVA_HOME_17_X64" >> $GITHUB_ENV
25+
uses: actions/setup-java@v4
26+
with:
27+
distribution: 'temurin'
28+
java-version: '17'
3229

3330
- name: Setup Node.js
3431
uses: actions/setup-node@v4
@@ -40,6 +37,10 @@ jobs:
4037
uses: subosito/flutter-action@v2
4138
with:
4239
channel: stable
40+
cache: true
41+
42+
- name: Cache Gradle
43+
uses: burrunan/gradle-cache-action@v1
4344

4445
- name: Install dependencies
4546
run: npm ci
@@ -57,17 +58,17 @@ jobs:
5758
run: |
5859
echo "${{ secrets.KEYSTORE }}" | base64 --decode > "android/app/keystore.jks"
5960
60-
- name: Release
61+
- name: Semantic Release
62+
uses: cycjimmy/semantic-release-action@v4
63+
id: semantic
6164
env:
6265
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6366
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
6467
KEYSTORE_ENTRY_ALIAS: ${{ secrets.KEYSTORE_ENTRY_ALIAS }}
6568
KEYSTORE_ENTRY_PASSWORD: ${{ secrets.KEYSTORE_ENTRY_PASSWORD }}
66-
run: |
67-
npx semantic-release
6869

69-
- name: Generate artifact attestation
70-
if: github.ref == 'refs/heads/main'
71-
uses: actions/attest-build-provenance@v1
70+
- name: Attest
71+
if: steps.semantic.outputs.new_release_published == 'true'
72+
uses: actions/attest-build-provenance@v2
7273
with:
7374
subject-path: build/app/outputs/apk/release/revanced-manager-*.apk

0 commit comments

Comments
 (0)