|
52 | 52 | changelog: "false"
|
53 | 53 | root_options: ${{ inputs.debug && '-vv --noop' || '-v --noop' }}
|
54 | 54 |
|
| 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 | +
|
55 | 78 | - name: Python Release
|
56 | 79 | id: release
|
57 | 80 | if: ${{ github.event_name == 'workflow_dispatch' && !inputs.dry_run }}
|
|
68 | 91 | IS_DRY_RUN="${{ steps.set_mode.outputs.is_dry_run }}"
|
69 | 92 | RELEASE_ID=$([ "$IS_DRY_RUN" = "true" ] && echo "release_dryrun" || echo "release")
|
70 | 93 | 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 |
71 | 96 | VERSION="${{ steps.release_dryrun.outputs.version || steps.release.outputs.version }}"
|
72 | 97 | TAG="${{ steps.release_dryrun.outputs.tag || steps.release.outputs.tag }}"
|
73 | 98 |
|
| 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 | +
|
74 | 112 | # Display trigger information
|
75 | 113 | if [ "${{ github.event_name }}" = "push" ]; then
|
76 | 114 | TRIGGER_INFO="Triggered by push to branch: ${{ github.ref_name }}"
|
|
0 commit comments