From 2f0974b938dcb3a240a9478ffaa39996c4b86384 Mon Sep 17 00:00:00 2001 From: E85Addict <77761710+E85Addict@users.noreply.github.com> Date: Fri, 6 Dec 2024 01:41:51 -0800 Subject: [PATCH] perf: Add upstream sync --- .github/workflows/clean.yml | 28 ++++++++++++++++ .github/workflows/release.yml | 1 + .github/workflows/sync_upstream.yml | 52 +++++++++++++++++++++++++++++ .releaserc | 10 +----- patches/build.gradle.kts | 2 +- 5 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/clean.yml create mode 100644 .github/workflows/sync_upstream.yml diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 0000000000..af94648ff8 --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,28 @@ +name: Delete old workflow runs +on: + workflow_dispatch: + inputs: + days: + description: 'Number of days.' + required: true + default: 0 + minimum_runs: + description: 'The minimum runs to keep for each workflow.' + required: true + default: 0 + delete_workflow_pattern: + description: 'The name of the workflow. if not set then it will target all workflows.' + required: false + +jobs: + del_runs: + runs-on: ubuntu-22.04 + steps: + - name: Delete workflow runs + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ github.token }} + repository: ${{ github.repository }} + retain_days: ${{ github.event.inputs.days }} + keep_minimum_runs: ${{ github.event.inputs.minimum_runs }} + delete_workflow_pattern: ${{ github.event.inputs.delete_workflow_pattern }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b682722f2..96dab5e2e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ name: Release on: + workflow_call: workflow_dispatch: push: branches: diff --git a/.github/workflows/sync_upstream.yml b/.github/workflows/sync_upstream.yml new file mode 100644 index 0000000000..034e024f44 --- /dev/null +++ b/.github/workflows/sync_upstream.yml @@ -0,0 +1,52 @@ +name: Sync upstream +on: + workflow_call: + workflow_dispatch: + schedule: + - cron: "0 */8 * * *" + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GH_PAT }} + + - name: sync + id: sync + shell: bash + run: | + git config --global user.name 'E85Addict' + git config --global user.email '77761710+E85Addict@users.noreply.github.com' + if [[ $(git log | grep Author | head -1) == *"semantic"* ]]; then + git reset --hard HEAD~1 + fi + T=$(git tag --sort=creatordate | tail -1) + git remote add upstream https://github.com/revanced/revanced-patches + git tag -d $(git tag -l) + git fetch upstream --tags -f + LatestRemoteTag=$(curl -s https://api.github.com/repos/revanced/revanced-patches/releases/latest | jq -r '.tag_name') + C=$(git rev-list --left-right --count origin/main...remotes/upstream/main | awk '{print$2}') + echo "Ahead $C commits." + + if [ "$C" -gt 0 ]; then + echo "Rebasing" + # git push origin --delete $T + git rebase -X ours upstream/main + git push --tags -f + git push origin --delete $LatestRemoteTag + git push -f + else + echo "in sync" + fi + + - name: Delete old workflow runs + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ github.token }} + repository: ${{ github.repository }} + retain_days: 0 + keep_minimum_runs: 10 \ No newline at end of file diff --git a/.releaserc b/.releaserc index b3d61b10b1..e7df65d1e9 100644 --- a/.releaserc +++ b/.releaserc @@ -14,7 +14,6 @@ ] } ], - "@semantic-release/release-notes-generator", "@semantic-release/changelog", "gradle-semantic-release-plugin", [ @@ -24,7 +23,7 @@ "CHANGELOG.md", "gradle.properties", ], - "message": "chore: Release v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + "message": "chore: Release v${nextRelease.version} [skip ci]\n\n'Add upstream sync'" } ], [ @@ -37,13 +36,6 @@ ], successComment: false } - ], - [ - "@saithodev/semantic-release-backmerge", - { - backmergeBranches: [{"from": "main", "to": "dev"}], - clearWorkspace: true - } ] ] } diff --git a/patches/build.gradle.kts b/patches/build.gradle.kts index 459d50a0ce..2c934264ee 100644 --- a/patches/build.gradle.kts +++ b/patches/build.gradle.kts @@ -31,7 +31,7 @@ publishing { repositories { maven { name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/revanced/revanced-patches") + url = uri("https://maven.pkg.github.com/E85Addicts/revanced-patches") credentials { username = System.getenv("GITHUB_ACTOR") password = System.getenv("GITHUB_TOKEN")