From b53f168c8a15df89090c3edb45020990d92837e4 Mon Sep 17 00:00:00 2001 From: CoderJoshDK <74162303+CoderJoshDK@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:27:08 -0400 Subject: [PATCH 1/2] fix: auto release on mirror updates --- .github/workflows/main.yml | 24 ++++++++++++++++++++++++ .github/workflows/release.yml | 20 -------------------- 2 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index adba977..b3b9677 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,6 +32,30 @@ jobs: - 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 + - run: | git push origin HEAD:refs/heads/main git push origin HEAD:refs/heads/main --tags + 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 }} + if: env.changes_exist == 'true' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index e933642..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Releases - -on: - push: - tags: - - 'v?[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/ruff/releases/tag/$TAG_NAME" - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1d4627a9828f6cf0c59cf79ccdc07620f42c786d Mon Sep 17 00:00:00 2001 From: CoderJoshDK <74162303+CoderJoshDK@users.noreply.github.com> Date: Wed, 3 Apr 2024 13:39:57 -0400 Subject: [PATCH 2/2] build: add names to commands for clarity --- .github/workflows/main.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b3b9677..3358a6e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,7 @@ jobs: - run: python mirror.py - - name: Check for unpushed commits + - name: check for unpushed commits id: check_unpushed run: | UNPUSHED_COMMITS=$(git log origin/main..HEAD) @@ -44,12 +44,15 @@ jobs: echo "changes_exist=true" >> $GITHUB_ENV fi - - run: | + - 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 - if: env.changes_exist == 'true' - - run: | + - 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" \ @@ -58,4 +61,3 @@ jobs: --latest env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: env.changes_exist == 'true'