Skip to content

Commit

Permalink
fix: auto release on mirror updates (#8)
Browse files Browse the repository at this point in the history
As mentioned in astral-sh/ruff-pre-commit#82 /
astral-sh/ruff-pre-commit#83, the auto release
function doesn't work. This fixes that by checking for changes and
setting a flag. If the flag is set, it will also create a new release
through gh cli.

Another note is that the `actions/setup-python` is updated from `v4` →
`v5`
 
This is being done now because it has been working well for the
ruff-pre-commit repo (I think?)
  • Loading branch information
CoderJoshDK authored Apr 16, 2024
1 parent 02b9a11 commit 61db430
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
30 changes: 28 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
20 changes: 0 additions & 20 deletions .github/workflows/release.yml

This file was deleted.

0 comments on commit 61db430

Please sign in to comment.