๐Ÿ“ฆ astral-sh / uv-pre-commit

๐Ÿ“„ main.yml ยท 67 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67name: main
on:
  schedule:
    - cron: "0 */4 * * *"
  workflow_dispatch:
  repository_dispatch:
    types: [pypi_release]

jobs:
  build:
    name: main
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - if: ${{ startsWith(github.event_name, 'repository_dispatch') }}
        run: sleep 30

      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          persist-credentials: true # needed to push commits below

      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
        with:
          python-version: "3.11"
          cache: pip
          cache-dependency-path: requirements-dev.txt

      - run: pip install -r requirements-dev.txt

      - name: set git config
        run: |
          git config user.name "$GITHUB_ACTOR"
          git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

      - run: python 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/uv/releases/tag/$TAG_NAME" \
            --latest
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}