0
0
mirror of https://github.com/TrianguloY/UrlChecker.git synced 2024-09-19 20:02:16 +02:00

build evaluation apk on prs

Idea from Ilithy
This commit is contained in:
TrianguloY 2023-04-14 18:27:26 +02:00
parent d07fb9157d
commit 2eeff09694
4 changed files with 80 additions and 1 deletions

View File

@ -0,0 +1,48 @@
# This action will send a comment to the pr for download the built apk.
# Needs to be as a separate action, artifacts are not available on the action used to upload them
name: Comment Artifact URL on PR
on:
workflow_run:
workflows:
- "Validate gradle build test"
types:
- "completed"
permissions:
actions: read # need to read the artifacts url
pull-requests: write # need to write the comment
jobs:
comment-on-pr:
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.pull_requests[0] != null
runs-on: ubuntu-latest
steps:
- name: Post url to artifact
timeout-minutes: 5
env:
GITHUB_TOKEN: ${{ github.token }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
PREVIOUS_JOB_ID: ${{ github.event.workflow_run.id }}
PREVIOUS_SUITE_ID: ${{ github.event.workflow_run.check_suite_id }}
PR_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
run: |
# get artifact id
while true; do
ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/runs/$PREVIOUS_JOB_ID/artifacts" --jq ".artifacts[0].id")
if [ -n "$ARTIFACT_ID" ]; then break; fi
# the artifact isn't available immediately, retry
echo No artifact, will retry shortly
sleep 10
done
echo "ARTIFACT ID: $ARTIFACT_ID"
# post link comment
gh api "/repos/$OWNER/$REPO/issues/$PR_NUMBER/comments" -F body=@- <<EOF
[Download testing apk](https://github.com/$OWNER/$REPO/suites/$PREVIOUS_SUITE_ID/artifacts/$ARTIFACT_ID)
This unsigned apk can be installed alongside the original app and should only be used for testing the changes, not for normal usage.
The link may expire in 90 days.
EOF

View File

@ -1,4 +1,5 @@
# This actions validates the gradle files and runs a build test to ensure the app is not corrupted
# if succeeded and the source is a pull request, builds an evaluation apk
name: Validate gradle build test
on:
@ -9,6 +10,11 @@ on:
branches:
- master
# parameters
env:
VARIANT: evaluation
NAME: URLCheck_evaluation.apk
jobs:
build:
runs-on: ubuntu-latest
@ -35,3 +41,20 @@ jobs:
arguments: >
build
test
# the following steps will only run for PRs
- name: Generate apk
if: ${{ github.event_name == 'pull_request' }}
uses: gradle/gradle-build-action@v2
with:
arguments: >
build
assemble${{ env.VARIANT }}
- name: Upload apk as artifact
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
path: ./app/build/outputs/apk/${{ env.VARIANT }}/app-${{ env.VARIANT }}.apk
name: ${{ env.NAME }}

View File

@ -52,6 +52,11 @@ android {
applicationIdSuffix '.alpha'
versionNameSuffix '-ALPHA'
}
evaluation {
initWith(buildTypes.debug)
applicationIdSuffix '.test'
versionNameSuffix '-TEST'
}
}
lint {

View File

@ -42,9 +42,12 @@ public class AboutActivity extends Activity {
setTitle(R.string.a_about);
AndroidUtils.configureUp(this);
// on release, append version to the action bar title
if (!BuildConfig.DEBUG) {
// on release, append version to the action bar title
setTitle(getTitle() + " (V" + BuildConfig.VERSION_NAME + ")");
} else if (!"alpha".equals(BuildConfig.BUILD_TYPE)) {
// on no-alpha, append type
setTitle(getTitle() + " (" + BuildConfig.BUILD_TYPE + ")");
}
// fill contributors and translators