Skip to content

Check for updates #2108

Check for updates

Check for updates #2108

Workflow file for this run

name: Check for updates
on:
push:
branches: [ main ]
paths: [ .github/workflows/stable-check.yml, scripts/**, crates/**, stable.template.yml ]
pull_request:
branches: [ main ]
paths: [ .github/workflows/stable-check.yml, scripts/**, crates/**, stable.template.yml, pr/_allowlist ]
workflow_dispatch:
schedule:
- cron: '0 6 * * *'
permissions: { }
env:
python-version: "3.13"
jobs:
check:
outputs:
crates: ${{ steps.check.outputs.crates }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}
- name: Skip Duplicate Actions
if: ${{ github.event_name != 'pull_request' }}
uses: fkirc/skip-duplicate-actions@v5
id: skip
with:
skip_after_successful_duplicate: false
do_not_skip: '["pull_request"]'
concurrent_skipping: always
- name: Check for updates
id: check
env:
IS_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
SHOULD_SKIP: ${{ steps.skip.outputs.should_skip }}
run: echo "crates=$(python ./scripts/check.py "${IS_PULL_REQUEST}" "${SHOULD_SKIP}" "${GITHUB_SERVER_URL}" "${GITHUB_REPOSITORY}")" >> "${GITHUB_OUTPUT}"
dispatch:
if: ${{ needs.check.outputs.crates != '{}' }}
strategy:
max-parallel: 1
matrix: ${{ fromJson(needs.check.outputs.crates) }}
runs-on: ubuntu-latest
needs: [ check ]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: ${{ env.python-version }}
- name: Generate workflow
env:
IS_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
MATRIX_CRATE: ${{ matrix.crate }}
MATRIX_VERSION: ${{ matrix.version }}
MATRIX_DL: ${{ matrix.dl }}
MATRIX_CHECKSUM: ${{ matrix.checksum }}
MATRIX_FILE: ${{ matrix.file }}
run: python ./scripts/gen.py "${IS_PULL_REQUEST}" "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" "${MATRIX_CRATE}" "${MATRIX_VERSION}" "${MATRIX_DL}" "${MATRIX_CHECKSUM}" "${MATRIX_FILE}"
- name: Print generated workflow file
env:
MATRIX_CRATE: ${{ matrix.crate }}
run: cat "./.github/workflows/stable-${MATRIX_CRATE}.yml"
- name: Wait
if: ${{ github.event_name != 'pull_request' }}
run: sleep 15m
- name: Run Generated Workflow
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
MATRIX_CRATE: ${{ matrix.crate }}
MATRIX_VERSION: ${{ matrix.version }}
MATRIX_FILE: ${{ matrix.file }}
run: |
set -euxo pipefail
TEMP_DIR="$(mktemp -d)"
# Move files
mkdir -p "${TEMP_DIR}/crates"
cp "${MATRIX_FILE}" "${TEMP_DIR}/crates"
mkdir -p "${TEMP_DIR}/.github/workflows"
cp "./.github/workflows/stable-${MATRIX_CRATE}.yml" "${TEMP_DIR}/.github/workflows"
cp -r 'keys' 'scripts' "${TEMP_DIR}"
rm -rf "${TEMP_DIR}/scripts/__pycache__"
# Commit and Push
pushd "${TEMP_DIR}"
git init
git config user.name 'github-actions'
git config user.email 'github-actions@noreply.github.com'
git remote add origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git checkout -b tmp
git add -f .
git commit -m "Publish crate ${MATRIX_CRATE} ${MATRIX_VERSION} from #${GITHUB_RUN_NUMBER}"
git push --force origin tmp:trigger/stable
# Cleanup
popd
rm -rf "${TEMP_DIR}"
wait:
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: [ dispatch ]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- run: sleep 15m
archive:
if: ${{ github.event_name != 'pull_request' }}
strategy:
max-parallel: 1
matrix:
type: [ stable ]
runs-on: ubuntu-latest
needs: [ wait ]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: archive
persist-credentials: false
fetch-depth: 0
- name: Clean
working-directory: ./${{ matrix.type }}
run: rm -rf ./*
- name: Archive
uses: robinraju/release-downloader@v1.11
with:
tag: "${{ matrix.type }}-index"
fileName: "*"
out-file-path: "./${{ matrix.type }}"
- name: Commit and Push
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euxo pipefail
git config --local user.name 'github-actions[bot]'
git config --local user.email 'github-actions[bot]@users.noreply.github.com'
git commit -a --allow-empty -m "chore: autopublish $(date --utc)"
git push "https://${GITHUB_ACTOR}:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:archive --follow-tags