Skip to content

Gradle を更新

Gradle を更新 #35

Workflow file for this run

name: Build
on:
push:
paths:
- '.github/workflows/build.yml'
- 'app/**'
- 'gradle/**'
- '*.gradle'
- '*.properties'
workflow_dispatch:
inputs:
release:
description: 'Release'
type: boolean
required: true
default: false
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Set environments
run: |
{
echo "version=v$(grep versionName app/build.gradle | awk '{print $2}' | tr -d \")"
echo "commit=$(echo ${{ github.sha }} | cut -c-7)"
echo "repo=$(echo ${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/})"
} >> $GITHUB_ENV
- name: Check tag exists
uses: mukunku/tag-exists-action@v1.6.0
if: github.event.inputs.release == 'true'
id: check-tag
with:
tag: "${{ env.version }}"
- name: Release check
if: github.event.inputs.release == 'true'
run: |
if [ "${{ secrets.STORE_FILE }}" == "" ]; then
echo -e "\nERROR!\nTo release, you need to set up a signing key!\n"
echo "STORE_FILE: A Base64 encoded string of the signing key in JKS format"
echo "STORE_PASSWORD: Key store password"
echo "KEY_ALIAS: Key alias"
echo "KEY_PASSWORD: Key password"
echo ""
exit 1
fi
if [ "${{ steps.check-tag.outputs.exists }}" == "true" ]; then
echo -e "\nERROR!\nThe same tag already exists!\n"
echo "Please change versionName in build.gradle"
echo ""
exit 1
fi
- name: Build with Gradle
run: |
if [ "${{ inputs.release }}" == "true" ]; then
echo "${{ secrets.STORE_FILE }}" | base64 -d > app/release.jks
export STORE_PASSWORD="${{ secrets.STORE_PASSWORD }}"
export KEY_ALIAS="${{ secrets.KEY_ALIAS }}"
export KEY_PASSWORD="${{ secrets.KEY_PASSWORD }}"
./gradlew assembleRelease bundleRelease
cp -f app/build/outputs/apk/release/app-release.apk ${{ env.repo }}-${{ env.version }}.apk
cp -f app/build/outputs/bundle/release/app-release.aab ${{ env.repo }}-${{ env.version }}.aab
else
./gradlew assembleDebug bundleDebug
cp -f app/build/outputs/apk/debug/app-debug.apk ${{ env.repo }}-${{ env.version }}@${{ env.commit }}.apk
cp -f app/build/outputs/bundle/debug/app-debug.aab ${{ env.repo }}-${{ env.version }}@${{ env.commit }}.aab
fi
- name: Attest
uses: actions/attest-build-provenance@v1
with:
subject-path: ${{ env.repo }}-${{ env.version }}*.a*
- name: Upload APK
uses: actions/upload-artifact@v4
with:
name: ${{ env.repo }}(${{ env.version }}@${{ env.commit }})
path: ${{ env.repo }}-${{ env.version }}*.a*
- name: Release
uses: softprops/action-gh-release@v2
if: github.event.inputs.release == 'true'
with:
tag_name: ${{ env.version }}
draft: true
prerelease: false
files: ${{ env.repo }}-${{ env.version }}.apk