diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c30dd5a..ee54c63 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.11" cache: pip @@ -31,6 +31,32 @@ jobs: - run: python mirror.py - - run: | + - 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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 00f504b..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Releases - -on: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]*' - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - run: | - TAG_NAME=${GITHUB_REF#refs/tags/} - gh release create "$TAG_NAME" \ - --title "$TAG_NAME" \ - --notes "See: https://github.com/astral-sh/uv/releases/tag/$TAG_NAME" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}