From 95c2781e3a7929f9a3b177d51021fa2270961737 Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Sun, 7 Feb 2021 16:51:19 +0200 Subject: [PATCH] Use gradle action to execute commands --- .github/workflows/deploy.yml | 22 +++++++----------- .github/workflows/main.yml | 20 +++++++---------- checksum.sh | 43 ------------------------------------ 3 files changed, 16 insertions(+), 69 deletions(-) delete mode 100755 checksum.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c82d35e..a0eddc1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -20,10 +20,11 @@ jobs: uses: metcalfc/changelog-generator@v0.4.4 with: myToken: ${{ secrets.GITHUB_TOKEN }} - - name: set up JDK 1.8 + - name: "Setup JDK 11" + id: setup-java uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: "11" - id: vars run: | echo ::set-output name=tag::${GITHUB_REF:10} @@ -35,19 +36,12 @@ jobs: echo ${{ secrets.GOOGLE_SERVICES }} | base64 -d | zcat >> app/google-services.json echo ${{ secrets.KEYSTORE_B64 }} | base64 -d | zcat >> app/pocketmode-release.keystore echo ${{ secrets.KEYSTORE_PROPS_B64 }} | base64 -d | zcat >> app/pocketmode-release.properties - - name: Generate cache key - run: ./checksum.sh . checksum.txt - - uses: actions/cache@v2 + - name: "./gradlew clean bundlePlaystoreRelease assemblePlaystoreRelease assembleOpensourceRelease" + uses: eskatos/gradle-command-action@v1 + env: + JAVA_HOME: ${{ steps.setup-java.outputs.path }} with: - path: | - ~/.gradle/caches/modules-* - ~/.gradle/caches/jars-* - ~/.gradle/caches/build-cache-* - key: gradle-${{ hashFiles('checksum.txt') }} - - name: build with Gradle - run: ./gradlew clean bundlePlaystoreRelease assemblePlaystoreRelease - - name: build with Gradle [oss] - run: ./gradlew assembleOpensourceRelease + arguments: clean bundlePlaystoreRelease assemblePlaystoreRelease assembleOpensourceRelease - name: create release id: create_release uses: actions/create-release@v1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f5bb4dc..3813259 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,23 +16,19 @@ jobs: steps: - uses: actions/checkout@master - - name: Set up JDK 1.8 + - name: "Setup JDK 11" + id: setup-java uses: actions/setup-java@v1 with: - java-version: 1.8 + java-version: "11" - name: Copy google-services.json run: | cd app echo ${{ secrets.GOOGLE_SERVICES }} | base64 -d | zcat >> google-services.json cd .. - - name: Generate cache key - run: ./checksum.sh . checksum.txt - - uses: actions/cache@v2 + - name: "./gradlew assemblePlaystoreDebug" + uses: eskatos/gradle-command-action@v1 + env: + JAVA_HOME: ${{ steps.setup-java.outputs.path }} with: - path: | - ~/.gradle/caches/modules-* - ~/.gradle/caches/jars-* - ~/.gradle/caches/build-cache-* - key: gradle-${{ hashFiles('checksum.txt') }} - - name: Run tests - run: ./gradlew assemblePlaystoreDebug + arguments: assemblePlaystoreDebug diff --git a/checksum.sh b/checksum.sh deleted file mode 100755 index c41607d..0000000 --- a/checksum.sh +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright 2019 Google, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# see: -# https://github.com/android/compose-samples/raw/main/scripts/checksum.sh - -#!/bin/bash -SAMPLE=$1 -RESULT_FILE=$2 - -if [ -f $RESULT_FILE ]; then - rm $RESULT_FILE -fi -touch $RESULT_FILE - -checksum_file() { - echo $(openssl md5 $1 | awk '{print $2}') -} - -FILES=() -while read -r -d ''; do - FILES+=("$REPLY") -done < <(find $SAMPLE -type f \( -name "build.gradle*" -o -name "gradle-wrapper.properties" \) -print0) - -# Loop through files and append MD5 to result file -for FILE in ${FILES[@]}; do - echo $(checksum_file $FILE) >> $RESULT_FILE -done -# Now sort the file so that it is -sort $RESULT_FILE -o $RESULT_FILE