Skip to content

Commit 98a225e

Browse files
author
anna-singleton-resolver
committed
ci: build and publish pre release version to pypy
1 parent 26c8819 commit 98a225e

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
branches:
66
- main
7+
- feature/*
8+
- fix/*
79
pull_request:
810
branches:
911
- main
@@ -111,7 +113,17 @@ jobs:
111113
echo "Setting version to: $VERSION"
112114
uv version "$VERSION"
113115
else
114-
echo "Not building from a tag, using default version"
116+
if [[ "$GITHUB_REF" == refs/heads/main ]]; then
117+
echo "On main branch, using default version"
118+
else
119+
# we want to build pre-release versioning for other branches, but only feature/* and fix/* will get published.
120+
BRANCH_NAME="${GITHUB_REF##*/}"
121+
SANITIZED_BRANCH_NAME=$(echo "$BRANCH_NAME" | tr '-' '_')
122+
SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-7)
123+
LAST_TAG=$(git describe --abbrev=0 --tags)
124+
VERSION="$LAST_TAG-${SANITIZED_BRANCH_NAME}_${SHORT_SHA}"
125+
uv version "$VERSION"
126+
fi
115127
fi
116128
117129
- name: Build package
@@ -126,7 +138,11 @@ jobs:
126138
publish:
127139
needs: [test, build]
128140
runs-on: ubuntu-latest
129-
if: github.event_name == 'release' && github.event.action == 'published'
141+
if: >
142+
(github.event_name == 'release' && github.event.action == 'published') ||
143+
(github.event_name == 'push' && (
144+
startsWith(github.ref, 'refs/heads/feature') ||
145+
startsWith(github.ref, 'refs/heads/fix')))
130146
environment:
131147
name: pypi
132148
url: https://pypi.org/p/resolver-athena-client

0 commit comments

Comments
 (0)