From 2b6485a44b3cde04a59f58400044b27b00ff644c Mon Sep 17 00:00:00 2001 From: CoderJoshDK <74162303+CoderJoshDK@users.noreply.github.com> Date: Wed, 3 Apr 2024 21:39:03 -0400 Subject: [PATCH] fix: auto release on mirror updates (#83) As mentioned in #82, there are issues with having a workflow triggered by the work done by a different workflow. To keep the functionality of the auto release workflow, the two files are being merged into one. Closes #82 --- .github/workflows/main.yml | 28 +++++++++++++++++++++++++++- .github/workflows/release.yml | 20 -------------------- 2 files changed, 27 insertions(+), 21 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index adba977..3358a6e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,6 +32,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 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 }}