mirror of
https://github.com/bolucat/Archive.git
synced 2026-04-23 00:17:16 +08:00
96 lines
3.4 KiB
YAML
96 lines
3.4 KiB
YAML
name: Check and Update xray-core
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 0 * * *'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
update:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout our repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: '0'
|
|
|
|
- name: Fetch latest release tag from external repository
|
|
id: fetch-release
|
|
run: |
|
|
EXTERNAL_REPO="XTLS/Xray-core"
|
|
LATEST_TAG=$(curl -s https://api.github.com/repos/$EXTERNAL_REPO/tags | jq -r '.[0]')
|
|
LATEST_TAG_NAME=$(echo $LATEST_TAG | jq -r .name)
|
|
LATEST_TAG_SHA=$(echo $LATEST_TAG | jq -r .commit.sha)
|
|
echo "Latest tag from external repo: $LATEST_TAG_NAME"
|
|
echo "LATEST_TAG_NAME=$LATEST_TAG_NAME" >> $GITHUB_ENV
|
|
echo "LATEST_TAG_SHA=$LATEST_TAG_SHA" >> $GITHUB_ENV
|
|
|
|
- name: Fetch current repository release tag
|
|
id: fetch-current-tag
|
|
run: |
|
|
CURRENT_TAG_NAME=$(git describe --tags --abbrev=0)
|
|
echo "Current tag in this repo: $CURRENT_TAG_NAME"
|
|
echo "CURRENT_TAG_NAME=$CURRENT_TAG_NAME" >> $GITHUB_ENV
|
|
|
|
- name: Compare tags
|
|
id: compare-tags
|
|
run: |
|
|
if [ "$LATEST_TAG_NAME" != "$CURRENT_TAG_NAME" ]; then
|
|
if [ "$(printf '%s\n' "$LATEST_TAG_NAME" "$CURRENT_TAG_NAME" | sort -V | tail -n1)" == "$CURRENT_TAG_NAME" ]; then
|
|
echo "Upstream LATEST_TAG_NAME less than the CURRENT_TAG_NAME, no update needed."
|
|
else
|
|
echo "Tags are different. Updating..."
|
|
echo "needs_update=true" >> $GITHUB_ENV
|
|
fi
|
|
else
|
|
echo "Tags are the same. No update needed."
|
|
echo "needs_update=false" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Setup Golang
|
|
if: env.needs_update == 'true'
|
|
uses: actions/setup-go@v5.4.0
|
|
with:
|
|
go-version: 'stable'
|
|
|
|
- name: Update and commit changes
|
|
if: env.needs_update == 'true'
|
|
run: |
|
|
# Lock gvisor version to a specific revision
|
|
go mod edit -replace=gvisor.dev/gvisor=gvisor.dev/gvisor@v0.0.0-20250606001031-fa4c4dd86b43
|
|
|
|
# Update specific dependency
|
|
go get github.com/xtls/xray-core@${{ env.LATEST_TAG_SHA }}
|
|
|
|
# Update all other dependencies
|
|
go get -u
|
|
go get gvisor.dev/gvisor@go
|
|
|
|
# Clean up and verify module dependencies
|
|
go mod tidy -v
|
|
|
|
# Show changes
|
|
git diff
|
|
|
|
- name: Commit and push changes
|
|
id: auto-commit-action
|
|
if: env.needs_update == 'true'
|
|
uses: stefanzweifel/git-auto-commit-action@v5.1.0
|
|
with:
|
|
commit_message: Updating xray-core to ${{ env.LATEST_TAG_NAME }} ${{ env.LATEST_TAG_SHA }}
|
|
tagging_message: ${{ env.LATEST_TAG_NAME }}
|
|
|
|
- name: Trigger build
|
|
if: env.needs_update == 'true' && steps.auto-commit-action.outputs.changes_detected == 'true'
|
|
run: |
|
|
curl -X POST \
|
|
-H "Accept: application/vnd.github.v3+json" \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
https://api.github.com/repos/${{ github.repository }}/actions/workflows/main.yml/dispatches \
|
|
-d "{
|
|
\"ref\": \"main\",
|
|
\"inputs\": {
|
|
\"release_tag\": \"${{ env.LATEST_TAG_NAME }}\"
|
|
}
|
|
}"
|