update 2026-09-24 10:46:53

This commit is contained in:
action committed 2026-09-24 10:46:53 +08:00
1 parent 907a158127
commit b31a5c3878
4914 files changed
-1716179

No files matched your search

-111
View File
@@ -1,111 +0,0 @@
name: Auto Update oxidns Version
on:
schedule:
# 每天 UTC 02:00 检查(北京时间 10:00)
- cron: '0 2 * * *'
workflow_dispatch: # 允许手动触发
permissions:
contents: write
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# 使用 GITHUB_TOKEN 推送;如果分支有保护规则需换成 PAT
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Get latest release tag from upstream
id: upstream
run: |
LATEST_TAG=$(curl -sL \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/svenshi/oxidns/releases/latest \
| jq -r '.tag_name')
if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "null" ]]; then
echo "::error::Failed to fetch latest release tag"
exit 1
fi
NEW_VERSION="${LATEST_TAG#v}"
echo "latest_tag=${LATEST_TAG}" >> "$GITHUB_OUTPUT"
echo "new_version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
echo "Latest tag: ${LATEST_TAG} (version: ${NEW_VERSION})"
- name: Get current version from Makefile
id: current
run: |
CURRENT_VERSION=$(grep -oP '^PKG_VERSION:=\K.*' Makefile)
echo "current_version=${CURRENT_VERSION}" >> "$GITHUB_OUTPUT"
echo "Current version: ${CURRENT_VERSION}"
- name: Compare versions
id: compare
run: |
if [ "${{ steps.current.outputs.current_version }}" = "${{ steps.upstream.outputs.new_version }}" ]; then
echo "update_needed=false" >> "$GITHUB_OUTPUT"
echo "Already up to date."
else
echo "update_needed=true" >> "$GITHUB_OUTPUT"
echo "Update needed: ${{ steps.current.outputs.current_version }} -> ${{ steps.upstream.outputs.new_version }}"
fi
- name: Get commit hash for the release tag
if: steps.compare.outputs.update_needed == 'true'
id: tag_commit
run: |
TAG="${{ steps.upstream.outputs.latest_tag }}"
REF_JSON=$(curl -sL \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/svenshi/oxidns/git/ref/tags/${TAG}")
OBJECT_TYPE=$(echo "$REF_JSON" | jq -r '.object.type')
COMMIT_SHA=$(echo "$REF_JSON" | jq -r '.object.sha')
# annotated tag 需要再解析一层
if [[ "$OBJECT_TYPE" == "tag" ]]; then
COMMIT_SHA=$(curl -sL \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/svenshi/oxidns/git/tags/${COMMIT_SHA}" \
| jq -r '.object.sha')
fi
if [[ -z "$COMMIT_SHA" || "$COMMIT_SHA" == "null" ]]; then
echo "::error::Failed to fetch commit hash for tag ${TAG}"
exit 1
fi
echo "commit_hash=${COMMIT_SHA}" >> "$GITHUB_OUTPUT"
echo "Commit hash: ${COMMIT_SHA}"
- name: Run update script
if: steps.compare.outputs.update_needed == 'true'
run: |
chmod +x update.sh
./update.sh \
"${{ steps.upstream.outputs.new_version }}" \
"${{ steps.tag_commit.outputs.commit_hash }}"
- name: Commit and push to current branch
if: steps.compare.outputs.update_needed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add Makefile
if git diff --cached --quiet; then
echo "No changes to commit."
exit 0
fi
git commit -m "oxidns: update to ${{ steps.upstream.outputs.new_version }} [skip ci]"
git push origin "HEAD:${{ github.ref_name }}"