From 3d7b6514e98d29aa6cf5ffad0103a94e15e4487a Mon Sep 17 00:00:00 2001 From: Mathieu Date: Thu, 2 May 2024 11:03:33 +0200 Subject: [PATCH] ci: Add workflow to automate the rebase and tag --- .github/workflows/android.yml | 16 +++++++- .github/workflows/rebase.yml | 70 +++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/rebase.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 536296ee..9f284ffe 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -6,6 +6,11 @@ on: - '*' tags: - '*' + workflow_dispatch: + inputs: + ref: + type: string + description: "The tag to use" jobs: build: @@ -14,7 +19,9 @@ jobs: steps: - name: checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.ref }} - name: setup jdk uses: actions/setup-java@v2 @@ -43,7 +50,7 @@ jobs: release: name: Sign/Release APK needs: build - if: startsWith(github.ref, 'refs/tags/v') + if: startsWith(inputs.ref || github.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: @@ -70,9 +77,14 @@ jobs: env: BUILD_TOOLS_VERSION: "32.0.0" + - name: 'Get Previous tag' + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@v1" + - name: Upload Release APK uses: softprops/action-gh-release@v1 with: + tag_name: ${{ steps.previoustag.outputs.tag }} files: | Olvid.apk Olvid-nogoogle.apk diff --git a/.github/workflows/rebase.yml b/.github/workflows/rebase.yml new file mode 100644 index 00000000..a802f464 --- /dev/null +++ b/.github/workflows/rebase.yml @@ -0,0 +1,70 @@ +name: Rebase and tag + +on: + workflow_dispatch: + # inputs: + # sync_test_mode: # Adds a boolean option that appears during manual workflow run for easy test mode config + # description: 'Test Mode' + # type: boolean + # default: false + +jobs: + sync_latest_from_upstream: + name: Sync latest commits from upstream repo and tag + runs-on: ubuntu-latest + permissions: + contents: write + steps: + + - name: checkout code + uses: actions/checkout@v4 + with: + ref: build-apk + fetch-depth: 0 + + - name: Sync upstream changes + id: sync + uses: aormsby/Fork-Sync-With-Upstream-action@v3.4.1 + with: + target_sync_branch: build-apk + # REQUIRED 'target_repo_token' exactly like this! + target_repo_token: ${{ secrets.GITHUB_TOKEN }} + target_branch_push_args: '--force' + upstream_sync_branch: main + upstream_sync_repo: olvid-io/olvid-android + upstream_pull_args: '--rebase --tags' + + # Set test_mode true during manual dispatch to run tests instead of the true action!! + test_mode: ${{ inputs.sync_test_mode }} + + - name: New commits found + if: steps.sync.outputs.has_new_commits == 'true' + run: echo "New commits were found to sync." + + - name: No new commits + if: steps.sync.outputs.has_new_commits == 'false' + run: echo "There were no new commits." + + - name: Show value of 'has_new_commits' + run: echo ${{ steps.sync.outputs.has_new_commits }} + + - name: 'Get Previous tag' + if: steps.sync.outputs.has_new_commits == 'true' + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@v1" + + - name: Bump version and push tag + if: steps.sync.outputs.has_new_commits == 'true' + uses: EndBug/latest-tag@latest + with: + github_token: ${{ secrets.GH_TOKEN }} + ref: "${{ steps.previoustag.outputs.tag }}-kumy1" + + - name: Trigger build + if: steps.sync.outputs.has_new_commits == 'true' + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + run: | + gh workflow run android.yml \ + -R kumy/olvid-android \ + -F "ref=refs/tags/${{ steps.previoustag.outputs.tag }}-kumy1"