Skip to content

Commit

Permalink
Use most recent release when creating stable branch the first time
Browse files Browse the repository at this point in the history
Refs #1, #2
  • Loading branch information
simonw authored Aug 21, 2023
1 parent d50b69f commit bd53b29
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/stable-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,27 @@ jobs:
run: |
git config user.name "Automated"
git config user.email "[email protected]"
- name: Check if stable branch exists
run: |
if ! git ls-remote --heads origin stable | grep stable; then
# Fetch all tags and sort them in descending order
LATEST_RELEASE=$(git tag | sort -Vr | head -n1)
# If no release is found, default to the main branch
if [ -z "$LATEST_RELEASE" ]; then
LATEST_RELEASE="main"
fi
# Check out the latest release or main branch
git checkout $LATEST_RELEASE
git checkout -b stable
git push -u origin stable
fi
- name: Handle Release
if: github.event_name == 'release'
run: |
git fetch --all
git checkout stable
git reset --hard ${GITHUB_REF#refs/tags/}
git push origin stable --force
- name: Handle Commit to Main
if: contains(github.event.head_commit.message, '!stable-docs')
run: |
Expand Down

0 comments on commit bd53b29

Please sign in to comment.