mirror of
https://github.com/Michatec/Radio.git
synced 2026-01-30 23:17:21 +00:00
Update gradle-publish.yml
This commit is contained in:
108
.github/workflows/gradle-publish.yml
vendored
108
.github/workflows/gradle-publish.yml
vendored
@@ -1,44 +1,84 @@
|
|||||||
# This workflow uses actions that are not certified by GitHub.
|
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
|
||||||
# They are provided by a third-party and are governed by
|
name: Build and publish APK
|
||||||
# separate terms of service, privacy policy, and support
|
on: [workflow_dispatch]
|
||||||
# documentation.
|
|
||||||
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
|
|
||||||
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
|
|
||||||
|
|
||||||
name: Gradle Package
|
env:
|
||||||
|
ANDROID_HOME: /usr/local/lib/android/sdk/
|
||||||
on:
|
APK_PATH: app/build/outputs/apk/release/app-release-unsigned.apk
|
||||||
release:
|
APKSIGNER: /usr/local/lib/android/sdk/build-tools/34.0.0/apksigner
|
||||||
types: [created]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout
|
||||||
- name: Set up JDK 17
|
uses: actions/checkout@v3
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
java-version: '17'
|
|
||||||
distribution: 'temurin'
|
|
||||||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
|
|
||||||
settings-path: ${{ github.workspace }} # location for the settings.xml file
|
|
||||||
|
|
||||||
- name: Setup Gradle
|
- name: Setup JDK
|
||||||
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: 17
|
||||||
|
distribution: adopt
|
||||||
|
cache: gradle
|
||||||
|
|
||||||
- name: Build with Gradle
|
- name: Cache Android SDK
|
||||||
run: ./gradlew build
|
#id: cache-android-sdk
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ env.ANDROID_HOME }}
|
||||||
|
key: ${{ runner.os }}-android-sdk
|
||||||
|
|
||||||
# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
|
- name: Setup Android SDK
|
||||||
# the publishing section of your build.gradle
|
## It is not necessary to check for cache hit as it
|
||||||
- name: Publish to GitHub Packages
|
## will not download Android SDK again
|
||||||
run: ./gradlew publish
|
#if: steps.cache-android-sdk.outputs.cache-hit != 'true'
|
||||||
env:
|
uses: android-actions/setup-android@v3
|
||||||
USERNAME: ${{ github.actor }}
|
with:
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
packages: ''
|
||||||
|
|
||||||
|
- name: Build unsigned APK
|
||||||
|
run: ./gradlew --no-daemon assembleRelease
|
||||||
|
|
||||||
|
- name: Sign APK
|
||||||
|
env:
|
||||||
|
SIGN_CERT: ${{ secrets.SIGN_CERT }}
|
||||||
|
SIGN_KEY: ${{ secrets.SIGN_KEY }}
|
||||||
|
run: |
|
||||||
|
# Copy APK file to app-release.apk
|
||||||
|
mv ${{ env.APK_PATH }} app-release.apk
|
||||||
|
# Decode certificate
|
||||||
|
echo -e $SIGN_CERT > cert.b64
|
||||||
|
base64 -d cert.b64 | tr -d '\n' > cert.der
|
||||||
|
# Decode key
|
||||||
|
echo -e $SIGN_KEY > key.b64
|
||||||
|
base64 -d key.b64 | tr -d '\n' > key.der
|
||||||
|
# Sign APK file with private key
|
||||||
|
${{ env.APKSIGNER }} sign --key key.der --cert cert.der app-release.apk
|
||||||
|
# Remove key files
|
||||||
|
rm cert.b64 key.b64 cert.der key.der
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: app-release
|
||||||
|
path: app-release.apk
|
||||||
|
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Download artifact
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: app-release
|
||||||
|
path: app-release.apk
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
artifacts: "app-release.apk"
|
||||||
|
draft: true
|
||||||
|
|||||||
Reference in New Issue
Block a user