Skip to content

Commit fb6f516

Browse files
ci: use a more explicit version number which includes the commit hash when not on main, prepare the CI for future auto-deploy
1 parent bba98c8 commit fb6f516

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.circleci/config.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,34 @@ jobs:
7676
steps:
7777
- attach_workspace:
7878
at: .
79+
- run:
80+
name: Set the version number
81+
command: |
82+
if [[ $CIRCLE_TAG ]]; then
83+
export PACKAGE_VERSION=$CIRCLE_TAG
84+
elif [[ $CIRCLE_BRANCH == << pipeline.parameters.publish-branch >> ]]; then
85+
# for main branches, can't add the commit hash since it's not a valid format for publishing
86+
export PACKAGE_VERSION=$(poetry version -s)$CIRCLE_BUILD_NUM
87+
else
88+
# for feature branches, add the commit hash
89+
export PACKAGE_VERSION=$(poetry version -s)$CIRCLE_BUILD_NUM+${CIRCLE_SHA1:0:7}
90+
fi
91+
# Display some debug info
92+
echo "Building a wheel release with version $PACKAGE_VERSION, build number: $CIRCLE_BUILD_NUM, commit hash: ${CIRCLE_SHA1:0:7}, tag: $CIRCLE_TAG."
93+
# Save the version number in a file
94+
echo "export PACKAGE_VERSION=\"$PACKAGE_VERSION\"" >> .env_vars
7995
- run:
8096
name: Build a distributable package
8197
command: |
98+
# Get the version number
99+
source .env_vars
82100
# Build a wheel release
83101
if [[ $CIRCLE_TAG ]]; then
84102
# This is a tagged release, version has been handled upstream
85103
poetry build
86104
else
87105
# Relies on a dev version like "1.2.1.dev" by default
88-
poetry version $(poetry version -s)$CIRCLE_BUILD_NUM
106+
poetry version $PACKAGE_VERSION
89107
poetry build
90108
fi
91109
- store_artifacts:

0 commit comments

Comments
 (0)