From bb280f33fbf4414cf6f4b39e4592ab11a36add89 Mon Sep 17 00:00:00 2001 From: Andrew Rowson Date: Tue, 23 Aug 2022 13:34:05 +0100 Subject: [PATCH] Fix setup-java step in release GH action --- .github/workflows/beta.yml | 119 ++++++++++++------------- .github/workflows/release.yml | 161 +++++++++++++++++----------------- 2 files changed, 141 insertions(+), 139 deletions(-) diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 1959001d08..489483c196 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -14,62 +14,63 @@ jobs: name: Create GH release and promote Play store internal to Beta runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Create release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - body_path: ./CHANGELOG.md - release_name: ${{ github.ref }} - draft: true - prerelease: true - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: 11 - - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Decrypt secrets - env: - GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }} - KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} - run: | - echo -n $GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS > project/app/owntracks-android-gcloud-creds.json - echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks - - name: Build APK - run: ./gradlew clean :app:getLatestVersionCodeMinusOne assembleRelease - working-directory: project - env: - KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }} - ORG_GRADLE_PROJECT_google_maps_api_key: ${{ secrets.GOOGLE_MAPS_API_KEY }} - MAKE_APK_SAME_VERSION_CODE_AS_GOOGLE_PLAY: yes - - name: Upload GMS Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./project/app/build/outputs/apk/gms/release/app-gms-release.apk - asset_name: owntracks-release-gms.apk - asset_content_type: application/vnd.android.package-archive - - name: Upload OSS Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./project/app/build/outputs/apk/oss/release/app-oss-release.apk - asset_name: owntracks-release-oss.apk - asset_content_type: application/vnd.android.package-archive - - name: Promote play store beta from internal - run: ./gradlew promoteArtifact --from-track internal --promote-track beta --release-status completed - working-directory: project + - uses: actions/checkout@v3 + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + body_path: ./CHANGELOG.md + release_name: ${{ github.ref }} + draft: true + prerelease: true + - name: set up JDK 11 + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: 11 + - uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Decrypt secrets + env: + GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }} + KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} + run: | + echo -n $GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS > project/app/owntracks-android-gcloud-creds.json + echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks + - name: Build APK + run: ./gradlew clean :app:getLatestVersionCodeMinusOne assembleRelease + working-directory: project + env: + KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }} + ORG_GRADLE_PROJECT_google_maps_api_key: ${{ secrets.GOOGLE_MAPS_API_KEY }} + MAKE_APK_SAME_VERSION_CODE_AS_GOOGLE_PLAY: yes + - name: Upload GMS Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./project/app/build/outputs/apk/gms/release/app-gms-release.apk + asset_name: owntracks-release-gms.apk + asset_content_type: application/vnd.android.package-archive + - name: Upload OSS Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./project/app/build/outputs/apk/oss/release/app-oss-release.apk + asset_name: owntracks-release-oss.apk + asset_content_type: application/vnd.android.package-archive + - name: Promote play store beta from internal + run: ./gradlew promoteArtifact --from-track internal --promote-track beta --release-status completed + working-directory: project diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7c83086007..11ad18216b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,83 +12,84 @@ jobs: name: Create GH release and promote Play store beta to release runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: octokit/request-action@v2.x - name: Find beta tags - id: get_beta_tags - with: - route: GET /repos/owntracks/android/git/matching-refs/tags/${{ github.ref }}-beta - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Get number of matching tags - id: tagCount - env: - labels: ${{ steps.get_beta_tags.outputs.data }} - run: | - echo $labels - export LENGTH=$(echo $labels | jq '. | length') - echo $LENGTH - echo "::set-output name=beta_tag_count::$LENGTH" - - name: Create release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - body_path: ./CHANGELOG.md - release_name: ${{ github.ref }} - draft: true - prerelease: false - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: 11 - - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - name: Decrypt secrets - env: - GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }} - KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} - run: | - echo -n $GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS > project/app/owntracks-android-gcloud-creds.json - echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks - - name: Build APK - run: ./gradlew clean :app:getLatestVersionCodeMinusOne assembleRelease - working-directory: project - env: - KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }} - ORG_GRADLE_PROJECT_google_maps_api_key: ${{ secrets.GOOGLE_MAPS_API_KEY }} - MAKE_APK_SAME_VERSION_CODE_AS_GOOGLE_PLAY: yes - - name: Upload GMS Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./project/app/build/outputs/apk/gms/release/app-gms-release.apk - asset_name: owntracks-release-gms.apk - asset_content_type: application/vnd.android.package-archive - - name: Upload OSS Release Asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps - asset_path: ./project/app/build/outputs/apk/oss/release/app-oss-release.apk - asset_name: owntracks-release-oss.apk - asset_content_type: application/vnd.android.package-archive - - name: Promote play store production from beta - run: ./gradlew promoteArtifact --from-track beta --promote-track production --release-status completed - working-directory: project - if: ${{ steps.tagCount.outputs.beta_tag_count > 0 }} - - name: Promote play store production from internal - run: ./gradlew promoteArtifact --from-track internal --promote-track production --release-status completed - working-directory: project - if: ${{ steps.tagCount.outputs.beta_tag_count == 0 }} + - uses: actions/checkout@v3 + - uses: octokit/request-action@v2.x + name: Find beta tags + id: get_beta_tags + with: + route: GET /repos/owntracks/android/git/matching-refs/tags/${{ github.ref }}-beta + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get number of matching tags + id: tagCount + env: + labels: ${{ steps.get_beta_tags.outputs.data }} + run: | + echo $labels + export LENGTH=$(echo $labels | jq '. | length') + echo $LENGTH + echo "::set-output name=beta_tag_count::$LENGTH" + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + body_path: ./CHANGELOG.md + release_name: ${{ github.ref }} + draft: true + prerelease: false + - name: set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: "temurin" + - uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Decrypt secrets + env: + GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }} + KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} + run: | + echo -n $GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS > project/app/owntracks-android-gcloud-creds.json + echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks + - name: Build APK + run: ./gradlew clean :app:getLatestVersionCodeMinusOne assembleRelease + working-directory: project + env: + KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }} + ORG_GRADLE_PROJECT_google_maps_api_key: ${{ secrets.GOOGLE_MAPS_API_KEY }} + MAKE_APK_SAME_VERSION_CODE_AS_GOOGLE_PLAY: yes + - name: Upload GMS Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./project/app/build/outputs/apk/gms/release/app-gms-release.apk + asset_name: owntracks-release-gms.apk + asset_content_type: application/vnd.android.package-archive + - name: Upload OSS Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./project/app/build/outputs/apk/oss/release/app-oss-release.apk + asset_name: owntracks-release-oss.apk + asset_content_type: application/vnd.android.package-archive + - name: Promote play store production from beta + run: ./gradlew promoteArtifact --from-track beta --promote-track production --release-status completed + working-directory: project + if: ${{ steps.tagCount.outputs.beta_tag_count > 0 }} + - name: Promote play store production from internal + run: ./gradlew promoteArtifact --from-track internal --promote-track production --release-status completed + working-directory: project + if: ${{ steps.tagCount.outputs.beta_tag_count == 0 }}