Skip to content

Commit 24df7de

Browse files
committed
get the version
1 parent b9d6db9 commit 24df7de

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/deploy-semantic-release.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,29 @@ jobs:
5252
changelog: "false"
5353
root_options: ${{ inputs.debug && '-vv --noop' || '-v --noop' }}
5454

55+
- name: Check Next Version (Dry Run)
56+
id: check_next_version
57+
if: steps.set_mode.outputs.is_dry_run == 'true' && steps.release_dryrun.outputs.version == ''
58+
shell: bash
59+
run: |
60+
# Run semantic-release with --noop to find next version without making changes
61+
OUTPUT=$(python -m semantic_release version --noop)
62+
echo "Output from semantic-release: $OUTPUT"
63+
64+
# Extract next version from output
65+
NEXT_VERSION=$(echo "$OUTPUT" | grep -oP 'would bump version to \K[0-9]+\.[0-9]+\.[0-9]+' || echo "")
66+
if [ -n "$NEXT_VERSION" ]; then
67+
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
68+
echo "next_tag=v$NEXT_VERSION" >> $GITHUB_OUTPUT
69+
echo "Found next version: $NEXT_VERSION"
70+
else
71+
# Fallback to current version if can't determine next
72+
CURRENT_VERSION=$(grep -m 1 'version = "' pyproject.toml | awk -F'"' '{print $2}' | sed 's/^v//')
73+
echo "next_version=${CURRENT_VERSION}.dev0" >> $GITHUB_OUTPUT
74+
echo "next_tag=v${CURRENT_VERSION}.dev0" >> $GITHUB_OUTPUT
75+
echo "Using current version with dev suffix: ${CURRENT_VERSION}.dev0"
76+
fi
77+
5578
- name: Python Release
5679
id: release
5780
if: ${{ github.event_name == 'workflow_dispatch' && !inputs.dry_run }}
@@ -68,9 +91,24 @@ jobs:
6891
IS_DRY_RUN="${{ steps.set_mode.outputs.is_dry_run }}"
6992
RELEASE_ID=$([ "$IS_DRY_RUN" = "true" ] && echo "release_dryrun" || echo "release")
7093
WAS_RELEASED=$([ "${{ steps.release_dryrun.outputs.released || steps.release.outputs.released }}" = "true" ] && echo "Yes" || echo "No")
94+
95+
# First try to get version from release outputs
7196
VERSION="${{ steps.release_dryrun.outputs.version || steps.release.outputs.version }}"
7297
TAG="${{ steps.release_dryrun.outputs.tag || steps.release.outputs.tag }}"
7398
99+
# If no version from release outputs, try to get from check_next_version step
100+
if [ "$IS_DRY_RUN" = "true" ] && [ -z "$VERSION" ]; then
101+
VERSION="${{ steps.check_next_version.outputs.next_version }}"
102+
TAG="${{ steps.check_next_version.outputs.next_tag }}"
103+
fi
104+
105+
# If still no version, use fallback
106+
if [ -z "$VERSION" ]; then
107+
CURRENT_VERSION=$(grep -m 1 'version = "' pyproject.toml | awk -F'"' '{print $2}' | sed 's/^v//')
108+
VERSION="${CURRENT_VERSION}.dev0"
109+
TAG="v${VERSION}"
110+
fi
111+
74112
# Display trigger information
75113
if [ "${{ github.event_name }}" = "push" ]; then
76114
TRIGGER_INFO="Triggered by push to branch: ${{ github.ref_name }}"

0 commit comments

Comments
 (0)