66 lines
2.0 KiB
YAML
66 lines
2.0 KiB
YAML
name: Build Android APK
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup JDK
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: '17'
|
|
distribution: 'temurin'
|
|
|
|
- name: Setup Android SDK
|
|
uses: android-actions/setup-android@v2
|
|
|
|
- name: Build with Gradle
|
|
run: |
|
|
chmod +x ./gradlew
|
|
./gradlew assembleRelease --no-daemon
|
|
|
|
- name: Upload APK
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: apk
|
|
path: app/build/outputs/apk/release/*.apk
|
|
|
|
- name: Create Release
|
|
run: |
|
|
set -x
|
|
TAG_NAME=${GITHUB_REF#refs/tags/}
|
|
APK_FILE=$(ls app/build/outputs/apk/release/*.apk | head -1)
|
|
|
|
echo "Tag: $TAG_NAME"
|
|
echo "APK: $APK_FILE"
|
|
echo "Token exists: ${{ secrets.GITHUB_TOKEN != '' }}"
|
|
|
|
TOKEN=${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# Create release
|
|
RELEASE_JSON=$(curl -s -X POST "https://git-dangilcal.duckdns.org/api/v1/repos/dangilcal/Helldivers-app-movil/releases" \
|
|
-H "accept: application/json" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Authorization: token $TOKEN" \
|
|
-d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"Release $TAG_NAME\", \"draft\": false, \"prerelease\": false}")
|
|
|
|
echo "Release created: $RELEASE_JSON"
|
|
|
|
RELEASE_ID=$(echo $RELEASE_JSON | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
|
|
|
echo "Release ID: $RELEASE_ID"
|
|
|
|
# Upload asset
|
|
curl -v -X POST "https://git-dangilcal.duckdns.org/api/v1/repos/dangilcal/Helldivers-app-movil/releases/$RELEASE_ID/assets" \
|
|
-H "accept: application/json" \
|
|
-H "Content-Type: multipart/form-data" \
|
|
-H "Authorization: token $TOKEN" \
|
|
-F "attachment=@$APK_FILE"
|