From c183393f8b1e840c8fce801f96fc2732a6efd37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Sat, 4 Jan 2025 18:50:50 +0800 Subject: [PATCH 1/7] Update Geodat cache per 12 hours --- .github/workflows/daily-prepare.yml | 60 +++++++++++++++++++++++++++++ .github/workflows/release-win7.yml | 46 +--------------------- .github/workflows/release.yml | 46 +--------------------- .github/workflows/test.yml | 2 +- 4 files changed, 63 insertions(+), 91 deletions(-) create mode 100644 .github/workflows/daily-prepare.yml diff --git a/.github/workflows/daily-prepare.yml b/.github/workflows/daily-prepare.yml new file mode 100644 index 000000000000..1f7abcdcd686 --- /dev/null +++ b/.github/workflows/daily-prepare.yml @@ -0,0 +1,60 @@ +name: Timely assets update + +# NOTE: This Github Actions is required by other actions, for preparing other packaging assets in a +# routine manner, for example: GeoIP/GeoSite. +# Currently updating: +# - Geodat (GeoIP/Geosite) + +on: + workflow_dispatch: + schedule: + # Update assets on 11:45 (UTC) and 23:45 (UTC), per 12 hours + - cron: '45 11,23 * * *' + push: + # Prevent triggering update request storm + paths: + - ".github/workflows/daily-prepare.yml" + +jobs: + geodat: + runs-on: ubuntu-latest + steps: + - name: Restore Geodat Cache + uses: actions/cache/restore@v4 + with: + path: resources + key: xray-geodat- + + - name: Update Geodat + id: update + uses: nick-fields/retry@v3 + with: + timeout_minutes: 60 + retry_wait_seconds: 60 + max_attempts: 60 + command: | + [ -d 'resources' ] || mkdir resources + LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') + for i in "${LIST[@]}" + do + INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) + FILE_NAME="${INFO[2]}.dat" + echo -e "Verifying HASH key..." + HASH="$(curl -sL "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" + if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then + continue + else + echo -e "Downloading https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat..." + curl -L "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} + echo -e "Verifying HASH key..." + [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } + echo "unhit=true" >> $GITHUB_OUTPUT + fi + done + + - name: Save Geodat Cache + uses: actions/cache/save@v4 + if: ${{ steps.update.outputs.unhit }} + with: + path: resources + key: xray-geodat-${{ github.sha }}-${{ github.run_number }} diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml index ae1dd35b566b..0d00634a53e6 100644 --- a/.github/workflows/release-win7.yml +++ b/.github/workflows/release-win7.yml @@ -15,51 +15,7 @@ on: types: [opened, synchronize, reopened] jobs: - prepare: - runs-on: ubuntu-latest - steps: - - name: Restore Cache - uses: actions/cache/restore@v4 - with: - path: resources - key: xray-geodat- - - - name: Update Geodat - id: update - uses: nick-fields/retry@v3 - with: - timeout_minutes: 60 - retry_wait_seconds: 60 - max_attempts: 60 - command: | - [ -d 'resources' ] || mkdir resources - LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') - for i in "${LIST[@]}" - do - INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) - FILE_NAME="${INFO[2]}.dat" - echo -e "Verifying HASH key..." - HASH="$(curl -sL "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" - if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then - continue - else - echo -e "Downloading https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat..." - curl -L "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} - echo -e "Verifying HASH key..." - [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } - echo "unhit=true" >> $GITHUB_OUTPUT - fi - done - - - name: Save Cache - uses: actions/cache/save@v4 - if: ${{ steps.update.outputs.unhit }} - with: - path: resources - key: xray-geodat-${{ github.sha }}-${{ github.run_number }} - build: - needs: prepare permissions: contents: write strategy: @@ -112,7 +68,7 @@ jobs: make find . -maxdepth 1 -type f -regex './\(wxray\|xray\).exe' -exec mv {} ./build_assets/ \; - - name: Restore Cache + - name: Restore Geodat Cache uses: actions/cache/restore@v4 with: path: resources diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dc6fa6fe51a5..7bc8c51d18cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,51 +15,7 @@ on: types: [opened, synchronize, reopened] jobs: - prepare: - runs-on: ubuntu-latest - steps: - - name: Restore Cache - uses: actions/cache/restore@v4 - with: - path: resources - key: xray-geodat- - - - name: Update Geodat - id: update - uses: nick-fields/retry@v3 - with: - timeout_minutes: 60 - retry_wait_seconds: 60 - max_attempts: 60 - command: | - [ -d 'resources' ] || mkdir resources - LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') - for i in "${LIST[@]}" - do - INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) - FILE_NAME="${INFO[2]}.dat" - echo -e "Verifying HASH key..." - HASH="$(curl -sL "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" - if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then - continue - else - echo -e "Downloading https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat..." - curl -L "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} - echo -e "Verifying HASH key..." - [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } - echo "unhit=true" >> $GITHUB_OUTPUT - fi - done - - - name: Save Cache - uses: actions/cache/save@v4 - if: ${{ steps.update.outputs.unhit }} - with: - path: resources - key: xray-geodat-${{ github.sha }}-${{ github.run_number }} - build: - needs: prepare permissions: contents: write strategy: @@ -176,7 +132,7 @@ jobs: make find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; - - name: Restore Cache + - name: Restore Geodat Cache uses: actions/cache/restore@v4 with: path: resources diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9620829acefe..7ef9de65382b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: with: go-version-file: go.mod check-latest: true - - name: Restore Cache + - name: Restore Geodat Cache uses: actions/cache/restore@v4 with: path: resources From 5cd2f3bc31b982fae6d0e76cb890ff4d1cbff2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Sat, 4 Jan 2025 19:10:44 +0800 Subject: [PATCH 2/7] Add trigger for pull request --- .github/workflows/daily-prepare.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/daily-prepare.yml b/.github/workflows/daily-prepare.yml index 1f7abcdcd686..2cd5d88560a8 100644 --- a/.github/workflows/daily-prepare.yml +++ b/.github/workflows/daily-prepare.yml @@ -14,6 +14,10 @@ on: # Prevent triggering update request storm paths: - ".github/workflows/daily-prepare.yml" + pull_request: + # Prevent triggering update request storm + paths: + - ".github/workflows/daily-prepare.yml" jobs: geodat: From 1c1a1961b19d134ba06a21672189f1b72639f50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Sat, 4 Jan 2025 20:01:07 +0800 Subject: [PATCH 3/7] Add triggers for release; Triggers adjustment --- .github/workflows/daily-prepare.yml | 3 +++ .github/workflows/docker.yml | 5 +++++ .github/workflows/release-win7.yml | 10 ++++++++++ .github/workflows/release.yml | 10 ++++++++++ .github/workflows/test.yml | 12 ++++++++++++ 5 files changed, 40 insertions(+) diff --git a/.github/workflows/daily-prepare.yml b/.github/workflows/daily-prepare.yml index 2cd5d88560a8..ebe9018046a9 100644 --- a/.github/workflows/daily-prepare.yml +++ b/.github/workflows/daily-prepare.yml @@ -10,6 +10,9 @@ on: schedule: # Update assets on 11:45 (UTC) and 23:45 (UTC), per 12 hours - cron: '45 11,23 * * *' + release: + # Check for update on release + types: [published] push: # Prevent triggering update request storm paths: diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c0945db36b02..268a2b7b1825 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,6 +6,11 @@ on: push: branches: - main + paths-ignore: + - '.github/build/*' + - '.github/ISSUE_TEMPLATE/*' + - '.github/dependabot.yml' + - '.gitignore' jobs: build-image: diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml index 0d00634a53e6..3465ad95ddc6 100644 --- a/.github/workflows/release-win7.yml +++ b/.github/workflows/release-win7.yml @@ -10,9 +10,19 @@ on: workflow_dispatch: release: types: [published] + paths-ignore: + - '.github/docker/*' + - '.github/ISSUE_TEMPLATE/*' + - '.github/dependabot.yml' + - '.gitignore' push: pull_request: types: [opened, synchronize, reopened] + paths-ignore: + - '.github/docker/*' + - '.github/ISSUE_TEMPLATE/*' + - '.github/dependabot.yml' + - '.gitignore' jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bc8c51d18cd..c59ef376635d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,9 +10,19 @@ on: workflow_dispatch: release: types: [published] + paths-ignore: + - '.github/docker/*' + - '.github/ISSUE_TEMPLATE/*' + - '.github/dependabot.yml' + - '.gitignore' push: pull_request: types: [opened, synchronize, reopened] + paths-ignore: + - '.github/docker/*' + - '.github/ISSUE_TEMPLATE/*' + - '.github/dependabot.yml' + - '.gitignore' jobs: build: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7ef9de65382b..90cb41e70364 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,8 +2,20 @@ name: Test on: push: + paths-ignore: + - '.github/build/*' + - '.github/docker/*' + - '.github/ISSUE_TEMPLATE/*' + - '.github/dependabot.yml' + - '.gitignore' pull_request: types: [opened, synchronize, reopened] + paths-ignore: + - '.github/build/*' + - '.github/docker/*' + - '.github/ISSUE_TEMPLATE/*' + - '.github/dependabot.yml' + - '.gitignore' jobs: test: From 33b6002ddecbd8e2a170a50a04d71a36ce01d89d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Sat, 4 Jan 2025 21:55:12 +0800 Subject: [PATCH 4/7] Hourly trigger --- .github/workflows/docker.yml | 5 ----- .../{daily-prepare.yml => hourly-prepare.yml} | 7 ++----- .github/workflows/release-win7.yml | 10 ---------- .github/workflows/release.yml | 10 ---------- .github/workflows/test.yml | 12 ------------ 5 files changed, 2 insertions(+), 42 deletions(-) rename .github/workflows/{daily-prepare.yml => hourly-prepare.yml} (93%) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 268a2b7b1825..c0945db36b02 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,11 +6,6 @@ on: push: branches: - main - paths-ignore: - - '.github/build/*' - - '.github/ISSUE_TEMPLATE/*' - - '.github/dependabot.yml' - - '.gitignore' jobs: build-image: diff --git a/.github/workflows/daily-prepare.yml b/.github/workflows/hourly-prepare.yml similarity index 93% rename from .github/workflows/daily-prepare.yml rename to .github/workflows/hourly-prepare.yml index ebe9018046a9..135b5a4bab82 100644 --- a/.github/workflows/daily-prepare.yml +++ b/.github/workflows/hourly-prepare.yml @@ -8,11 +8,8 @@ name: Timely assets update on: workflow_dispatch: schedule: - # Update assets on 11:45 (UTC) and 23:45 (UTC), per 12 hours - - cron: '45 11,23 * * *' - release: - # Check for update on release - types: [published] + # Update assets on every hour (xx:45) + - cron: '45 * * * *' push: # Prevent triggering update request storm paths: diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml index 3465ad95ddc6..0d00634a53e6 100644 --- a/.github/workflows/release-win7.yml +++ b/.github/workflows/release-win7.yml @@ -10,19 +10,9 @@ on: workflow_dispatch: release: types: [published] - paths-ignore: - - '.github/docker/*' - - '.github/ISSUE_TEMPLATE/*' - - '.github/dependabot.yml' - - '.gitignore' push: pull_request: types: [opened, synchronize, reopened] - paths-ignore: - - '.github/docker/*' - - '.github/ISSUE_TEMPLATE/*' - - '.github/dependabot.yml' - - '.gitignore' jobs: build: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c59ef376635d..7bc8c51d18cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,19 +10,9 @@ on: workflow_dispatch: release: types: [published] - paths-ignore: - - '.github/docker/*' - - '.github/ISSUE_TEMPLATE/*' - - '.github/dependabot.yml' - - '.gitignore' push: pull_request: types: [opened, synchronize, reopened] - paths-ignore: - - '.github/docker/*' - - '.github/ISSUE_TEMPLATE/*' - - '.github/dependabot.yml' - - '.gitignore' jobs: build: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 90cb41e70364..7ef9de65382b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,20 +2,8 @@ name: Test on: push: - paths-ignore: - - '.github/build/*' - - '.github/docker/*' - - '.github/ISSUE_TEMPLATE/*' - - '.github/dependabot.yml' - - '.gitignore' pull_request: types: [opened, synchronize, reopened] - paths-ignore: - - '.github/build/*' - - '.github/docker/*' - - '.github/ISSUE_TEMPLATE/*' - - '.github/dependabot.yml' - - '.gitignore' jobs: test: From 0375ab8cf54607abf3fbf2b2e9d7db9e0e5401c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Sat, 4 Jan 2025 22:00:39 +0800 Subject: [PATCH 5/7] Set time on x:00 --- .github/workflows/hourly-prepare.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hourly-prepare.yml b/.github/workflows/hourly-prepare.yml index 135b5a4bab82..62e34381c40d 100644 --- a/.github/workflows/hourly-prepare.yml +++ b/.github/workflows/hourly-prepare.yml @@ -8,8 +8,8 @@ name: Timely assets update on: workflow_dispatch: schedule: - # Update assets on every hour (xx:45) - - cron: '45 * * * *' + # Update assets on every hour (xx:00) + - cron: '0 * * * *' push: # Prevent triggering update request storm paths: From f2356d80055e20452a5f30687b2331548644d93d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Sat, 4 Jan 2025 22:01:27 +0800 Subject: [PATCH 6/7] Set timer to xx:30 --- .github/workflows/hourly-prepare.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hourly-prepare.yml b/.github/workflows/hourly-prepare.yml index 62e34381c40d..dd766bde59a4 100644 --- a/.github/workflows/hourly-prepare.yml +++ b/.github/workflows/hourly-prepare.yml @@ -8,8 +8,8 @@ name: Timely assets update on: workflow_dispatch: schedule: - # Update assets on every hour (xx:00) - - cron: '0 * * * *' + # Update assets on every hour (xx:30) + - cron: '30 * * * *' push: # Prevent triggering update request storm paths: From a69096357d3e25f2b3359b9c8ea256fb2ac8bb05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Sat, 4 Jan 2025 22:10:30 +0800 Subject: [PATCH 7/7] Rename remnants --- .github/workflows/hourly-prepare.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/hourly-prepare.yml b/.github/workflows/hourly-prepare.yml index dd766bde59a4..d07c1ee349b4 100644 --- a/.github/workflows/hourly-prepare.yml +++ b/.github/workflows/hourly-prepare.yml @@ -13,11 +13,11 @@ on: push: # Prevent triggering update request storm paths: - - ".github/workflows/daily-prepare.yml" + - ".github/workflows/hourly-prepare.yml" pull_request: # Prevent triggering update request storm paths: - - ".github/workflows/daily-prepare.yml" + - ".github/workflows/hourly-prepare.yml" jobs: geodat: