From 1e5328ed186e097c252781cdad4fb6ed26fbbf3c Mon Sep 17 00:00:00 2001 From: AbdallahMehiz Date: Thu, 29 Aug 2024 07:04:28 +0100 Subject: [PATCH] chore: replace preview workflow with a release one * and bump version --- .github/workflows/preview.yml | 120 ---------------------------------- .github/workflows/release.yml | 86 ++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 120 deletions(-) delete mode 100644 .github/workflows/preview.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml deleted file mode 100644 index d762eca..0000000 --- a/.github/workflows/preview.yml +++ /dev/null @@ -1,120 +0,0 @@ -name: Make Pre-release - -permissions: - contents: write - -on: - workflow_dispatch: - inputs: - dry-run: - description: Creates a draft release - required: false - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup JDK 17 - uses: actions/setup-java@v4 - with: - distribution: 'adopt' - java-version: 17 - cache: 'gradle' - - - name: Make gradlew executable - run: chmod +x ./gradlew - - - name: Get previous preview - id: last_release - uses: InsonusK/get-latest-release@v1.1.0 - with: - myToken: ${{ github.token }} - exclude_types: "draft" - view_top: 1 - - - name: Prepare build - run: | - set -e - - commit_count=$(git rev-list --count HEAD) - echo "COMMIT_COUNT=$commit_count" >> $GITHUB_ENV - current_sha=$(git rev-parse HEAD) - echo "CURRENT_SHA=$current_sha" >> $GITHUB_ENV - prev_commit_count=$(echo "${{ steps.last_release.outputs.tag_name }}" | sed -e "s/^r//") - commit_count_diff=$(expr $commit_count - $prev_commit_count) - [ $commit_count_diff != 0 ] || exit 1 - commit_count_diff_plus_one=$(expr $commit_count_diff + 1) - prev_release_sha=$(git log --topo-order -n $commit_count_diff_plus_one --skip $commit_count_diff --max-count 1 --pretty=format:"%H") - echo "PREV_RELEASE_SHA=$prev_release_sha" >> $GITHUB_ENV - - echo "COMMIT_LOGS<<{delimiter} - $(curl -H "Accept: application/vnd.github.v3+json" \ - "https://api.github.com/repos/abdallahmehiz/mpvKt/compare/$prev_release_sha...$current_sha" \ - | jq '[.commits[]|{message:(.commit.message | split("\n")), username:.author.login}]' \ - | jq -r '.[]|"- \(.message | first) (@\(.username))"') - {delimiter}" >> $GITHUB_ENV - - - name: Build with Gradle - run: ./gradlew assemblePreview - - - name: Sign apk - uses: r0adkll/sign-android-release@v1 - with: - releaseDirectory: app/build/outputs/apk/preview - signingKeyBase64: ${{ secrets.SIGNING_KEYSTORE }} - alias: ${{ secrets.SIGNING_KEY_ALIAS }} - keyStorePassword: ${{ secrets.SIGNING_STORE_PASSWORD }} - keyPassword: ${{ secrets.KEY_PASSWORD }} - env: - BUILD_TOOLS_VERSION: "34.0.0" - - - name: Copy build artifacts - run: | - set -e - - declare -a apks=("universal" "arm64-v8a" "armeabi-v7a" "x86" "x86_64") - - printf "%s\n" "${apks[@]}" | xargs -n 1 -I {} sh -c ' - cp app/build/outputs/apk/preview/app-{}-preview-signed.apk mpvKt-{}-r${{ env.COMMIT_COUNT }}.apk - sha=$(sha256sum mpvKt-{}-r${{ env.COMMIT_COUNT }}.apk | awk '\''{ print $1 }'\'') - echo "apk-{}-sha256=$sha" >> $GITHUB_ENV' - - - name: Create release - uses: softprops/action-gh-release@v1 - with: - tag_name: r${{ env.COMMIT_COUNT }} - name: mpvKt Preview r${{ env.COMMIT_COUNT }} - body: | - ### Commits - - https://github.com/abdallahmehiz/mpvKt/compare/${{ env.PREV_RELEASE_SHA }}...${{ env.CURRENT_SHA }} - - ${{ env.COMMIT_LOGS }} - - --- - - ### Checksums - - | Variant | SHA-256 | - | ------- | ------- | - | arm64-v8a | ${{ env.apk-arm64-v8a-sha256 }} - | armeabi-v7a | ${{ env.apk-armeabi-v7a-sha256 }} - | Universal | ${{ env.apk-universal-sha256 }} - | x86 | ${{ env.apk-x86-sha256 }} - | x86_64 | ${{ env.apk-x86_64-sha256 }} | - files: | - mpvKt-universal-r${{ env.COMMIT_COUNT }}.apk - mpvKt-arm64-v8a-r${{ env.COMMIT_COUNT }}.apk - mpvKt-armeabi-v7a-r${{ env.COMMIT_COUNT }}.apk - mpvKt-x86-r${{ env.COMMIT_COUNT }}.apk - mpvKt-x86_64-r${{ env.COMMIT_COUNT }}.apk - draft: ${{ github.event.inputs.dry-run != '' }} - prerelease: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6265851 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,86 @@ +name: Make release + +permissions: + contents: write + +on: + push: + tags: + - v* + +jobs: + release-for-github: + name: "Release for GitHub and F-Droid" + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: 17 + + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Build release with Gradle + run: ./gradlew assembleRelease + + - name: Get tag ame + if: startsWith(github.ref, 'refs/tags/') + run: | + set -x + echo "VERSION_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Sign apk + uses: r0adkll/sign-android-release@v1 + with: + releaseDirectory: app/build/outputs/apk/release + signingKeyBase64: ${{ secrets.SIGNING_KEYSTORE }} + alias: ${{ secrets.SIGNING_KEY_ALIAS }} + keyStorePassword: ${{ secrets.SIGNING_STORE_PASSWORD }} + keyPassword: ${{ secrets.KEY_PASSWORD }} + env: + BUILD_TOOLS_VERSION: "34.0.0" + + - name: Copy build artifacts + run: | + set -e + + declare -a apks=("universal" "arm64-v8a" "armeabi-v7a" "x86" "x86_64") + + printf "%s\n" "${apks[@]}" | xargs -n 1 -I {} sh -c ' + cp app/build/outputs/apk/release/app-{}-release-unsigned-signed.apk mpvKt-{}-${{ env.VERSION_TAG }}.apk + sha=$(sha256sum mpvKt-{}-r${{ env.COMMIT_COUNT }}.apk | awk '\''{ print $1 }'\'') + echo "apk-{}-sha256=$sha" >> $GITHUB_ENV' + + - name: Create release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.VERSION_TAG }} + name: mpvKt ${{ env.VERSION_TAG }} + body: | + --- + + ### Checksums + + | Variant | SHA-256 | + | ------- | ------- | + | arm64-v8a | ${{ env.apk-arm64-v8a-sha256 }} + | armeabi-v7a | ${{ env.apk-armeabi-v7a-sha256 }} + | Universal | ${{ env.apk-universal-sha256 }} + | x86 | ${{ env.apk-x86-sha256 }} + | x86_64 | ${{ env.apk-x86_64-sha256 }} | + files: | + mpvKt-universal-${{ env.VERSION_TAG }}.apk + mpvKt-arm64-v8a-${{ env.VERSION_TAG }}.apk + mpvKt-armeabi-v7a-${{ env.VERSION_TAG }}.apk + mpvKt-x86-${{ env.VERSION_TAG }}.apk + mpvKt-x86_64-${{ env.VERSION_TAG }}.apk + prerelease: false + draft: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file