Skip to content

Commit

Permalink
Tweak CD for builds
Browse files Browse the repository at this point in the history
  • Loading branch information
zer0def committed Jul 29, 2023
1 parent b1c5333 commit 88ea23b
Showing 1 changed file with 24 additions and 32 deletions.
56 changes: 24 additions & 32 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
name: Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew assembleDebug

- name: Upload APK
uses: actions/[email protected]
with:
name: APK
path: app/build/outputs/apk/debug/app-debug.apk

- name: Upload lint report
uses: actions/[email protected]
with:
name: Lint report
path: app/build/reports/lint-results-debug.html
- uses: actions/checkout@v3

- name: JDK 8 setup
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

- name: Build artifacts
run: chmod +x gradlew; ./gradlew --no-daemon --stacktrace assembleDebug

- name: Publish artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
api_uri="https://api.github.com/repos/${GITHUB_REPOSITORY}/releases"
upload_uri="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases"
tag=$(awk '/(^|\s)versionName\s/ {print $NF}' app/build.gradle | sed 's/["'\'']//g')-$(awk '/(^|\s)versionCode\s/ {print $NF}' app/build.gradle | sed 's/["'\'']//g')-$(date -u +%Y%m%d)
id=$(echo "{\"tag_name\":\"${tag}\",\"name\":\"${tag}-debug\",\"body\":\"${tag}\",\"draft\":true}" | curl -fs -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/json" -d@- "${api_uri}" | jq -r .id)
curl -fs -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/octet-stream" -o /dev/null --data-binary "@app/build/outputs/apk/debug/app-debug.apk" "${upload_uri}/${id}/assets?name=${GITHUB_REPOSITORY##*/}-${tag}-debug.apk"
echo '{"draft":false}' | curl -fs -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/json" -d@- -o /dev/null -XPATCH "${api_uri}/${id}"

0 comments on commit 88ea23b

Please sign in to comment.