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: Install coreutils run: sudo apt-get install -y coreutils - name: Check and initialize go.mod run: | [ -f go.mod ] || (echo "Error: go.mod not found" && exit 1) if [ ! -f go.sum ]; then echo "Initializing go.sum..." go mod tidy fi - 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 # Получаем последний релизный тег через GitHub API release_info=$(curl -s https://api.github.com/repos/xtls/xray-core/releases/latest) tag_name=$(echo "$release_info" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') # Обновляем xray-core/v25 до последнего релизного тега go get github.com/xtls/xray-core/v25@$tag_name # Очистка и проверка 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/v25 to $tag_name" git push origin HEAD:${{ github.ref }}