
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary From my reading of the [UV docs](https://docs.astral.sh/uv/guides/scripts/), `mirror.py` would be a good example of a standalone script. This PR updates `mirror.py` and the `main.yml` workflow to be a UV script and makes use of UV in the update process. ## Test Plan - Update the uv version (currently 0.8.4) to an older version e.g. 0.8.3 in both `pyproject.toml` and `README.md` - Run `uv run --no-project mirror.py` to check the update process still works as expected
58 lines
1.6 KiB
YAML
58 lines
1.6 KiB
YAML
name: main
|
|
on:
|
|
schedule:
|
|
- cron: "0 */4 * * *"
|
|
workflow_dispatch:
|
|
repository_dispatch:
|
|
types: [pypi_release]
|
|
|
|
jobs:
|
|
build:
|
|
name: main
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- if: ${{ startsWith(github.event_name, 'repository_dispatch') }}
|
|
run: sleep 30
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v5
|
|
|
|
- name: set git config
|
|
run: |
|
|
git config user.name "$GITHUB_ACTOR"
|
|
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
|
|
|
- run: uv run --no-project mirror.py
|
|
|
|
- name: check for unpushed commits
|
|
id: check_unpushed
|
|
run: |
|
|
UNPUSHED_COMMITS=$(git log origin/main..HEAD)
|
|
if [ -z "$UNPUSHED_COMMITS" ]; then
|
|
echo "No unpushed commits found."
|
|
echo "changes_exist=false" >> $GITHUB_ENV
|
|
else
|
|
echo "Unpushed commits found."
|
|
echo "changes_exist=true" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: push changes if they exist
|
|
if: env.changes_exist == 'true'
|
|
run: |
|
|
git push origin HEAD:refs/heads/main
|
|
git push origin HEAD:refs/heads/main --tags
|
|
|
|
- name: create release on new tag if new changes exist
|
|
if: env.changes_exist == 'true'
|
|
run: |
|
|
TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1))
|
|
echo $TAG_NAME
|
|
gh release create "$TAG_NAME" \
|
|
--title "$TAG_NAME" \
|
|
--notes "See: https://github.com/astral-sh/ruff/releases/tag/${TAG_NAME/v}" \
|
|
--latest
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|