name: Update Go Dependencies on: schedule: - cron: '0 0 * * 1' workflow_dispatch: permissions: contents: write jobs: update: runs-on: ubuntu-latest timeout-minutes: 30 steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Go uses: actions/setup-go@v5 with: go-version-file: go.mod check-latest: true cache: true - name: Check go.mod and go.sum exist run: | [ -f go.mod ] || (echo "Error: go.mod not found" && exit 1) [ -f go.sum ] || (go mod tidy && echo "Initialized go.sum") - name: Clean Go module cache run: go clean -modcache && go clean -cache - name: Update dependencies id: update run: | set -euo pipefail # Обновляем стандартные зависимости go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all \ | grep -v -e 'gvisor.dev/gvisor' -e 'github.com/xtls/xray-core' \ | xargs -r go get -u # Получаем последний релизный тег и его коммит echo "Fetching latest xray-core release tag..." latest_tag=$(git ls-remote --tags https://github.com/xtls/xray-core \ | awk -F'[/ ]' '{print $3}' \ | grep '^v' \ | sort -V \ | tail -n1) echo "Latest release tag: $latest_tag" # Получаем хэш коммита для тега commit_hash=$(git ls-remote https://github.com/xtls/xray-core refs/tags/$latest_tag \ | awk '{print $1}') echo "Associated commit hash: $commit_hash" # Обновляем до конкретного коммита (будет сгенерирована псевдоверсия) go get github.com/xtls/xray-core@$commit_hash # Форсируем правильный формат псевдоверсии go mod edit -require github.com/xtls/xray-core@v0.0.0-$(echo $commit_hash | sed 's/\(.\{12\}\).*/\1/')-$(date -d @$(echo $commit_hash | cut -c1-8) +%Y%m%d%H%M%S) go mod tidy go mod verify - name: Check for changes id: check run: | if git diff --quiet go.mod go.sum; then echo "changes=false" >> $GITHUB_OUTPUT else echo "changes=true" >> $GITHUB_OUTPUT git diff go.mod fi - name: Commit and push changes if: steps.check.outputs.changes == 'true' run: | git config --global user.name "github-actions[bot]" git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" git add go.mod go.sum git commit -m "chore(deps): update xray-core to pseudo-version" git push origin HEAD:${{ github.ref }}