Skip to content

Commit

Permalink
chore(ci): add action to check for new versions
Browse files Browse the repository at this point in the history
  • Loading branch information
moetayuko committed Apr 16, 2024
1 parent 8d3efca commit 4d23e63
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 6 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,22 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Fetch upstream git reversion
id: op_version
run: echo sha=$(cat .nvchecker/sha) >> $GITHUB_OUTPUT

- name: Build Package
uses: openwrt/gh-action-sdk@main
env:
ARCH: ${{ matrix.arch }}-main
V: s
IGNORE_ERRORS: n m y
NO_DEFAULT_FEEDS: 1
EXTRA_FEEDS: >-
src-git-full|base|https://github.com/openwrt/openwrt.git
src-git|packages|https://github.com/openwrt/packages.git^${{ steps.op_version.outputs.sha }}
PACKAGES: cloudflared

- name: Finding failure logs
working-directory: logs/package/feeds
run: |
sed -ne 's!^ *ERROR: package/feeds/\(passwall[^ ]*\) .*$!\1!p' ../error.txt | sort -u | xargs -r find > ../../../logs.txt
cat ../../../logs.txt
- name: Upload Output Folder
uses: actions/upload-artifact@v4
with:
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/version-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Check new version

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
check:
name: Check and Update Version
runs-on: ubuntu-latest
steps:
- name: Setup Python 3
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install nvchecker
run: pip3 install nvchecker

- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}

- name: Fetch upstream git reversion
id: op_version
run: |
curl "https://api.github.com/repos/openwrt/packages/commits?sha=master&path=net/cloudflared&per_page=1" |
jq -r ".[0].sha" | (read sha; echo sha=$sha >> $GITHUB_OUTPUT)
- name: Compare version
env:
OP_VERSION: ${{ steps.op_version.outputs.sha }}
working-directory: .nvchecker
id: version
run: |
envsubst < config.toml.in > config.toml
nvchecker -c config.toml
nvcmp -c config.toml --exit-status && exit || echo "ret=$?" >> $GITHUB_OUTPUT
nvtake -c config.toml --all
echo "new=$(jq -r .cloudflared new_ver.json)" >> $GITHUB_OUTPUT
echo $OP_VERSION > sha
- name: Commit new version
if: steps.version.outputs.ret == 4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: update to ${{ steps.version.outputs.new }}"
tagging_message: ${{ steps.version.outputs.new }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*~
/.nvchecker/config.toml
/.nvchecker/new_ver.json
18 changes: 18 additions & 0 deletions .nvchecker/config.toml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[__config__]
oldver = "cur_ver.json"
newver = "new_ver.json"

[cloudflared-ver]
source = "regex"
regex = 'PKG_VERSION\s*:=\s*(.*)'
url = "https://raw.githubusercontent.com/openwrt/packages/${OP_VERSION}/net/cloudflared/Makefile"

[cloudflared-rel]
source = "regex"
regex = 'PKG_RELEASE\s*:=\s*(.*)'
url = "https://raw.githubusercontent.com/openwrt/packages/${OP_VERSION}/net/cloudflared/Makefile"

[cloudflared]
source = "combiner"
from = ["cloudflared-ver", "cloudflared-rel"]
format = "$1-r$2"
5 changes: 5 additions & 0 deletions .nvchecker/cur_ver.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"cloudflared": "2024.3.0-r1",
"cloudflared-rel": "1",
"cloudflared-ver": "2024.3.0"
}
1 change: 1 addition & 0 deletions .nvchecker/sha
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bcb75533851c51bff4628d4273d2388d7007f6c8

0 comments on commit 4d23e63

Please sign in to comment.