Skip to content

Build

Build #8

Workflow file for this run

name: Build
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- 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}"