From c901dcdfe2d561443b366f669c3ea6c6cb808849 Mon Sep 17 00:00:00 2001 From: Syuugo Date: Sat, 20 Jan 2024 12:15:42 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=83=AA=E3=83=BC=E3=82=B9=E7=94=A8?= =?UTF-8?q?=E3=81=AB=E6=9C=80=E9=81=A9=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 07003e71..ca9e252d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,6 +24,8 @@ jobs: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Java uses: actions/setup-java@v4 @@ -39,16 +41,34 @@ jobs: ~/.gradle/wrapper/ key: ${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} - - name: Build with Gradle + - name: Set environments run: | - if [[ "${{ inputs.release }}" == "true" ]] && [[ "${{ secrets.STORE_FILE }}" == "" ]]; then + { + echo "version=$(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: Release check + if: inputs.release == 'true' + run: | + if [[ "${{ secrets.STORE_FILE }}" == "" ]]; then echo -e "\nERROR!\n\nリリースするには、 署名鍵を設定する必要があります。\n\n" echo "STORE_FILE: JKS形式の署名鍵をBase64でエンコードした文字列" echo "STORE_PASSWORD: キーストアのパスワード" echo "KEY_ALIAS: 署名のエイリアス" echo "KEY_PASSWORD: 署名のパスワード" exit 1 - elif [[ "${{ inputs.release }}" == "true" ]]; then + fi + if git show-ref --tags --verify --quiet "refs/tags/${{ env.version }}"; then + echo -e "\nERROR!\n\n既に同じタグが存在します。\n\n" + echo "build.gradle の versionName を変更してください" + 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 }}" @@ -58,12 +78,6 @@ jobs: ./gradlew assemble --no-daemon fi - { - echo "version=$(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: Upload APK uses: actions/upload-artifact@v4 with: @@ -77,4 +91,4 @@ jobs: tag_name: v${{ env.version }} draft: true prerelease: false - files: app/build/outputs/apk/release/app-release.apk \ No newline at end of file + files: app/build/outputs/apk/release/app-release.apk