Update update-dependencies.yml

This commit is contained in:
civisrom 2025-03-04 14:14:15 +03:00 committed by GitHub
parent 0546eb2d55
commit b2294e46bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,33 +1,27 @@
name: Update Go Dependencies name: Update Go Dependencies
on: on:
schedule: schedule:
- cron: '0 0 * *1' # Запуск каждую неделю в понедельник в 00:00 UTC - cron: '0 0 * *1' # Запуск каждую неделю в понедельник в 00:00 UTC
workflow_dispatch: # Возможность ручного запуска workflow_dispatch: # Возможность ручного запуска
permissions: permissions:
contents: write # Явное указание разрешений contents: write # Явное указание разрешений
jobs: jobs:
update: update:
runs-on: ubuntu-latest # Используем последнюю версию Ubuntu runs-on: ubuntu-latest # Используем последнюю версию Ubuntu
timeout-minutes: 30 # Добавляем таймаут для предотвращения зависания timeout-minutes: 30 # Добавляем таймаут для предотвращения зависания
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 # Загружаем всю историю fetch-depth: 0 # Загружаем всю историю
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v5 uses: actions/setup-go@v5
with: with:
go-version-file: go.mod go-version-file: go.mod
check-latest: true check-latest: true
cache: true # Включаем кэширование модулей cache: true # Включаем кэширование модулей
- name: Check go.mod and go.sum exist - name: Check go.mod and go.sum exist
run: | run: |
if [ ! -f go.mod ]; then if [ ! -f go.mod ]; then
@ -40,20 +34,10 @@ jobs:
echo "go.sum file not found, initializing it..." echo "go.sum file not found, initializing it..."
go mod tidy go mod tidy
fi fi
- name: Clean Go module cache - name: Clean Go module cache
run: | run: |
go clean -modcache go clean -modcache
go clean -cache go clean -cache
- name: Get latest Xray release tag
id: xray-release
run: |
# Получаем последний release tag из GitHub API
LATEST_TAG=$(curl -s https://api.github.com/repos/xtls/xray-core/releases/latest | jq -r .tag_name)
echo "xray_version=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "Latest Xray release tag: $LATEST_TAG"
- name: Update dependencies - name: Update dependencies
id: update id: update
run: | run: |
@ -61,14 +45,16 @@ jobs:
echo "Updating standard Go dependencies..." echo "Updating standard Go dependencies..."
# Обновляем стандартные зависимости с исключением gvisor и xray-core # Обновляем стандартные зависимости с исключением gvisor
go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all | \ go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all | \
grep -v 'gvisor.dev/gvisor' | \ grep -v 'gvisor.dev/gvisor' | \
grep -v 'github.com/xtls/xray-core' | \ grep -v 'github.com/xtls/xray-core' | \
xargs -r go get -u xargs -r go get -u
echo "Specifically updating xray-core to latest release tag: ${{ steps.xray-release.outputs.xray_version }}" echo "Specifically updating xray-core to latest release..."
go get github.com/xtls/xray-core/v25@${{ steps.xray-release.outputs.xray_version }} # Получаем последний тег релиза и обновляем xray-core до него
LATEST_RELEASE=$(curl -s https://api.github.com/repos/xtls/xray-core/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
go get github.com/xtls/xray-core@$LATEST_RELEASE
# Проверяем, какую версию получили # Проверяем, какую версию получили
echo "Updated xray-core to:" echo "Updated xray-core to:"
@ -81,7 +67,6 @@ jobs:
# Выводим изменения для лога # Выводим изменения для лога
echo "Updated dependencies:" echo "Updated dependencies:"
go list -m all go list -m all
- name: Check for changes - name: Check for changes
id: check id: check
run: | run: |
@ -94,20 +79,16 @@ jobs:
# Добавляем || true чтобы предотвратить код ошибки, если grep ничего не находит # Добавляем || true чтобы предотвратить код ошибки, если grep ничего не находит
git diff go.mod || true git diff go.mod || true
fi fi
- name: Commit and push changes - name: Commit and push changes
if: steps.check.outputs.changes == 'true' if: steps.check.outputs.changes == 'true'
run: | run: |
git config --global user.name "github-actions[bot]" git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Получаем версию Xray для коммит-сообщения
XRAY_VERSION="${{ steps.xray-release.outputs.xray_version }}"
git add go.mod go.sum git add go.mod go.sum
git commit -m "chore(deps): update Go dependencies git commit -m "chore(deps): update Go dependencies
Automated update of Go dependencies including xray-core to version $XRAY_VERSION" Automated update of Go dependencies including xray-core to latest stable version"
# Попытка push с повторами при ошибках # Попытка push с повторами при ошибках
max_attempts=3 max_attempts=3