Skip to content

Commit

Permalink
ci(release): allow releasing a tag on an older commit; improve branch…
Browse files Browse the repository at this point in the history
… checking
  • Loading branch information
chanshing committed Jul 24, 2024
1 parent 246a2fe commit ca156ea
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ permissions:

jobs:
build-n-publish:
if: github.event.base_ref == 'refs/heads/main' || github.event.base_ref == 'refs/heads/master'
name: Publish to PyPI
runs-on: ubuntu-latest

Expand All @@ -24,6 +23,21 @@ jobs:
# A shallow clone can work when the following issue is resolved:
# https://github.com/actions/checkout/issues/338
fetch-depth: 0

- name: Check branch for tag
run: |
BRANCH_NAME=$(git branch --contains ${{ github.ref }} | grep -E 'main|master' | xargs)
if [[ -z "$BRANCH_NAME" ]]; then
echo "##[error]Tag is not in main or master branch."
exit 1
fi
- name: Fetch the latest tag
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Latest tag is $LATEST_TAG"
git checkout $LATEST_TAG
- name: Setup Java
uses: actions/setup-java@v4
Expand Down

0 comments on commit ca156ea

Please sign in to comment.