@@ -48,14 +48,19 @@ jobs:
4848 create-release :
4949 runs-on : ubuntu-latest
5050 outputs :
51- tag : ${{ steps.tag_name .outputs.tag }}
52- version : ${{ steps.new_version .outputs.version }}
51+ tag : ${{ steps.versions .outputs.tag }}
52+ version : ${{ steps.versions .outputs.pkg_version }}
5353 steps :
5454 - name : Output Inputs
5555 run : echo "${{ toJSON(github.event.inputs) }}"
5656
5757 - name : Checkout repo
5858 uses : actions/checkout@v4
59+ with :
60+ ref : main
61+ token : ${{ secrets.LANCE_RELEASE_TOKEN }}
62+ fetch-depth : 0
63+
5964 - name : Set up Python
6065 uses : actions/setup-python@v5
6166 with :
@@ -77,83 +82,105 @@ jobs:
7782 CURRENT_VERSION=$(python -c "import toml; print(toml.load('.bumpversion.toml')['tool']['bumpversion']['current_version'])")
7883 echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
7984 echo "Current version: $CURRENT_VERSION"
80- - name : Calculate new version
81- id : new_version
85+ - name : Calculate base version
86+ id : base_version
8287 run : |
8388 python ci/calculate_version.py \
8489 --current "${{ steps.current_version.outputs.version }}" \
8590 --type "${{ inputs.release_type }}" \
8691 --channel "${{ inputs.release_channel }}"
87- - name : Determine tag name
88- id : tag_name
92+
93+ - name : Determine tag and package version
94+ id : versions
8995 run : |
96+ BASE_VERSION="${{ steps.base_version.outputs.version }}"
97+ CURRENT_VERSION="${{ steps.current_version.outputs.version }}"
9098 if [ "${{ inputs.release_channel }}" == "stable" ]; then
91- VERSION="${{ steps.new_version.outputs.version } }"
92- TAG="v${VERSION }"
99+ TAG="v${BASE_VERSION }"
100+ PKG_VERSION="${BASE_VERSION }"
93101 else
94- # For preview releases, use current version with beta suffix
95- VERSION="${{ steps.current_version.outputs.version }}"
96- # Find the next beta number for current version
97- BETA_TAGS=$(git tag -l "v${VERSION}-beta.*" | sort -V)
102+ # For preview releases, find the next beta number for this base version
103+ BETA_TAGS=$(git tag -l "v${BASE_VERSION}-beta.*" | sort -V)
98104 if [ -z "$BETA_TAGS" ]; then
99105 BETA_NUM=1
100106 else
101107 LAST_BETA=$(echo "$BETA_TAGS" | tail -n 1)
102- LAST_NUM=$(echo "$LAST_BETA" | sed "s/v${VERSION }-beta.//")
108+ LAST_NUM=$(echo "$LAST_BETA" | sed "s/v${BASE_VERSION }-beta.//")
103109 BETA_NUM=$((LAST_NUM + 1))
104110 fi
105- TAG="v${VERSION}-beta.${BETA_NUM}"
111+ TAG="v${BASE_VERSION}-beta.${BETA_NUM}"
112+ # For preview releases, package version should include the beta suffix
113+ PKG_VERSION="${BASE_VERSION}-beta.${BETA_NUM}"
114+ fi
115+
116+ # Check if version actually changes (needed for commit/push decisions)
117+ if [ "$CURRENT_VERSION" != "$PKG_VERSION" ]; then
118+ VERSION_CHANGED="true"
119+ else
120+ VERSION_CHANGED="false"
106121 fi
107122
108123 echo "tag=$TAG" >> $GITHUB_OUTPUT
124+ echo "pkg_version=$PKG_VERSION" >> $GITHUB_OUTPUT
125+ echo "version_changed=$VERSION_CHANGED" >> $GITHUB_OUTPUT
109126 echo "Tag will be: $TAG"
127+ echo "Package version will be: $PKG_VERSION"
128+ echo "Version changed: $VERSION_CHANGED"
110129 - name : Configure git identity
111130 run : |
112131 git config user.name 'Lance Release Bot'
113132 git config user.email 'dev+gha@lance.org'
114- - name : Update version (stable releases only )
115- if : inputs.release_channel == 'stable '
133+ - name : Update version (when version changes )
134+ if : steps.versions.outputs.version_changed == 'true '
116135 run : |
117- python ci/bump_version.py --version "${{ steps.new_version .outputs.version }}"
136+ python ci/bump_version.py --version "${{ steps.versions .outputs.pkg_version }}"
118137 git diff
119- - name : Create release commit (stable releases only)
120- if : inputs.release_channel == 'stable'
138+
139+ - name : Create release commit (when version changes)
140+ if : steps.versions.outputs.version_changed == 'true'
121141 run : |
122142 git add -A
123- git commit -m "chore: release version ${{ steps.new_version.outputs.version }}" || echo "No changes to commit"
143+ git commit -m "chore: bump version to ${{ steps.versions.outputs.pkg_version }}" || echo "No changes to commit"
144+
124145 - name : Create tag
125146 run : |
126- git tag -a "${{ steps.tag_name.outputs.tag }}" -m "Release ${{ steps.tag_name.outputs.tag }}"
147+ git tag -a "${{ steps.versions.outputs.tag }}" -m "Release ${{ steps.versions.outputs.tag }}"
148+
127149 - name : Push changes (if not dry run)
128150 if : ${{ !inputs.dry_run }}
151+ env :
152+ GITHUB_TOKEN : ${{ secrets.LANCE_RELEASE_TOKEN }}
129153 run : |
130- if [ "${{ inputs.release_channel }}" == "stable" ]; then
131- # Push the commit for stable releases
154+ # Configure git to use the token for authentication
155+ git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
156+
157+ if [ "${{ steps.versions.outputs.version_changed }}" == "true" ]; then
158+ # Push the version bump commit
132159 git push origin main
133160 fi
134161 # Always push the tag
135- git push origin "${{ steps.tag_name .outputs.tag }}"
162+ git push origin "${{ steps.versions .outputs.tag }}"
136163 - name : Create GitHub Release Draft (if not dry run)
137164 if : ${{ !inputs.dry_run }}
138165 uses : softprops/action-gh-release@v2
139166 with :
140- tag_name : ${{ steps.tag_name .outputs.tag }}
141- name : ${{ steps.tag_name .outputs.tag }}
167+ tag_name : ${{ steps.versions .outputs.tag }}
168+ name : ${{ steps.versions .outputs.tag }}
142169 generate_release_notes : true
143170 draft : true
144171 prerelease : ${{ inputs.release_channel == 'preview' }}
145- token : ${{ secrets.GITHUB_TOKEN }}
172+ token : ${{ secrets.LANCE_RELEASE_TOKEN }}
146173 - name : Summary
147174 run : |
148175 echo "## Release Summary" >> $GITHUB_STEP_SUMMARY
149176 echo "" >> $GITHUB_STEP_SUMMARY
150177 echo "- **Release Type:** ${{ inputs.release_type }}" >> $GITHUB_STEP_SUMMARY
151178 echo "- **Release Channel:** ${{ inputs.release_channel }}" >> $GITHUB_STEP_SUMMARY
152179 echo "- **Current Version:** ${{ steps.current_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
153- if [ "${{ inputs.release_channel }}" == "stable " ]; then
154- echo "- **New Version:** ${{ steps.new_version .outputs.version }}" >> $GITHUB_STEP_SUMMARY
180+ if [ "${{ steps.versions.outputs.version_changed }}" == "true " ]; then
181+ echo "- **New Version:** ${{ steps.versions .outputs.pkg_version }}" >> $GITHUB_STEP_SUMMARY
155182 fi
156- echo "- **Tag:** ${{ steps.tag_name .outputs.tag }}" >> $GITHUB_STEP_SUMMARY
183+ echo "- **Tag:** ${{ steps.versions .outputs.tag }}" >> $GITHUB_STEP_SUMMARY
157184 echo "- **Dry Run:** ${{ inputs.dry_run }}" >> $GITHUB_STEP_SUMMARY
158185
159186 if [ "${{ inputs.dry_run }}" == "true" ]; then
@@ -172,6 +199,6 @@ jobs:
172199 echo " - Trigger automatic publishing to Maven Central and PyPI" >> $GITHUB_STEP_SUMMARY
173200 else
174201 echo " - Create a preview/beta release" >> $GITHUB_STEP_SUMMARY
175- echo " - Note: Preview releases are not published to package repositories " >> $GITHUB_STEP_SUMMARY
202+ echo " - Trigger automatic publishing to Maven Central and PyPI (as pre-release version) " >> $GITHUB_STEP_SUMMARY
176203 fi
177204 fi
0 commit comments