@@ -42,21 +42,18 @@ runs:
4242 id : increment
4343 shell : bash
4444 run : |
45- # Get current version
4645 CURRENT_VERSION=$(grep '^version = ' Project.toml | sed 's/version = "\(.*\)"/\1/')
4746 echo "Current version: $CURRENT_VERSION"
4847
49- # Strip any pre-release/build suffix before parsing. A version like
50- # "0.1.0-DEV" (everything the kit scaffolds starts life pre-release,
51- # unregistered) has never been published, so the correct transition is
52- # to RELEASE what the number already says — drop the suffix — not to
53- # increment past it. Without this, `IFS='.'` leaves PATCH as "0-DEV" and
54- # `$(( PATCH + 1 ))` coerces the "-DEV" to 0 and yields 1, so the maiden
55- # published version would be 0.1.1 and 0.1.0 would be silently skipped
56- # (#255).
48+ # Strip any pre-release/build suffix before parsing. Everything the
49+ # kit scaffolds starts pre-release ("0.1.0-DEV") and unpublished, so
50+ # the correct transition is to RELEASE what the number already says,
51+ # not increment past it. Without this, `IFS='.'` leaves PATCH as
52+ # "0-DEV" and `$(( PATCH + 1 ))` coerces it to 1, so the maiden
53+ # published version would be 0.1.1 and 0.1.0 silently skipped (#255).
5754 BASE_VERSION="${CURRENT_VERSION%%[-+]*}"
5855
59- # Parse version parts from the released base, so PATCH is a clean number .
56+ # Parse version parts from the released base, so PATCH is clean.
6057 IFS='.' read -ra VERSION_PARTS <<< "$BASE_VERSION"
6158 MAJOR=${VERSION_PARTS[0]}
6259 MINOR=${VERSION_PARTS[1]}
6865 echo "Pre-release version '$CURRENT_VERSION' detected: releasing" \
6966 "$NEW_VERSION (suffix stripped, no increment)."
7067 else
71- # A plain released version: apply the requested increment.
7268 case "${{ inputs.increment-type }}" in
7369 "major")
7470 NEW_MAJOR=$((MAJOR + 1))
9389 echo "old-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
9490 echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT
9591
96- # Update Project.toml
9792 sed -i "s/version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/" Project.toml
9893
9994 - name : Check for existing PR
10398 run : |
10499 NEW_VERSION="${{ steps.increment.outputs.new-version }}"
105100
106- # Check if a PR already exists with the same version
107101 EXISTING_PR=$(gh pr list --state open --search "in:title \"${{ inputs.pr-title-prefix }} to $NEW_VERSION\"" --json number --jq '.[0].number // empty')
108102
109103 if [ -n "$EXISTING_PR" ]; then
@@ -120,19 +114,16 @@ runs:
120114 if : inputs.create-pr == 'true' && steps.check-pr.outputs.existing-pr == 'false'
121115 shell : bash
122116 run : |
123- # Configure git
124117 git config --local user.email "action@github.com"
125118 git config --local user.name "GitHub Action"
126119
127120 OLD_VERSION="${{ steps.increment.outputs.old-version }}"
128121 NEW_VERSION="${{ steps.increment.outputs.new-version }}"
129122 INCREMENT_TYPE="${{ inputs.increment-type }}"
130123
131- # Create new branch
132124 BRANCH_NAME="auto/version-increment-${NEW_VERSION}"
133125 git checkout -b "$BRANCH_NAME"
134126
135- # Commit changes
136127 git add Project.toml
137128 git commit -m "${{ inputs.pr-title-prefix }} to $NEW_VERSION
138129
@@ -141,7 +132,6 @@ runs:
141132 Previous version: $OLD_VERSION
142133 New version: $NEW_VERSION"
143134
144- # Push branch
145135 git push origin "$BRANCH_NAME"
146136
147137 # Only assign when a handle was configured. Assigning a bare org (the
@@ -152,7 +142,6 @@ runs:
152142 ASSIGNEE_ARGS=(--assignee "${{ inputs.assignee }}")
153143 fi
154144
155- # Create PR using GitHub CLI
156145 PR_OUTPUT=$(gh pr create \
157146 --title "${{ inputs.pr-title-prefix }} to $NEW_VERSION" \
158147 --body "This PR automatically increments the version from \`$OLD_VERSION\` to \`$NEW_VERSION\` as a **$INCREMENT_TYPE** release.
@@ -176,7 +165,6 @@ runs:
176165 --head "$BRANCH_NAME" \
177166 "${ASSIGNEE_ARGS[@]}")
178167
179- # Extract PR number
180168 PR_NUMBER=$(echo "$PR_OUTPUT" | grep -o '/pull/[0-9]*' | grep -o '[0-9]*')
181169 echo "pr-number=$PR_NUMBER" >> $GITHUB_OUTPUT
182170 echo "Created PR #$PR_NUMBER"
@@ -194,15 +182,13 @@ runs:
194182 if : inputs.create-pr == 'false'
195183 shell : bash
196184 run : |
197- # Configure git
198185 git config --local user.email "action@github.com"
199186 git config --local user.name "GitHub Action"
200187
201188 OLD_VERSION="${{ steps.increment.outputs.old-version }}"
202189 NEW_VERSION="${{ steps.increment.outputs.new-version }}"
203190 INCREMENT_TYPE="${{ inputs.increment-type }}"
204191
205- # Commit changes
206192 git add Project.toml
207193 git commit -m "${{ inputs.pr-title-prefix }} to $NEW_VERSION
208194
@@ -211,5 +197,4 @@ runs:
211197 Previous version: $OLD_VERSION
212198 New version: $NEW_VERSION"
213199
214- # Push to current branch
215200 git pull && git push
0 commit comments