-
Notifications
You must be signed in to change notification settings - Fork 18
Add version bump option to publish workflow #748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,7 @@ on: | |||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||
| inputs: | ||||||||||||||||||
| tag: | ||||||||||||||||||
| description: 'Release tag' | ||||||||||||||||||
| description: 'Release tag (version like 0.0.246 or prerelease name like beta/alpha/rc)' | ||||||||||||||||||
| required: true | ||||||||||||||||||
| type: string | ||||||||||||||||||
| branch: | ||||||||||||||||||
|
|
@@ -17,95 +17,93 @@ jobs: | |||||||||||||||||
| build: | ||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||
| permissions: | ||||||||||||||||||
| contents: write # For git push and tagging | ||||||||||||||||||
| id-token: write # For OIDC trusted publishing to npm | ||||||||||||||||||
| contents: write | ||||||||||||||||||
| id-token: write | ||||||||||||||||||
| steps: | ||||||||||||||||||
| - name: Set tag from input (manual trigger) | ||||||||||||||||||
| if: github.event_name == 'workflow_dispatch' | ||||||||||||||||||
| - name: Set tag and version type | ||||||||||||||||||
| run: | | ||||||||||||||||||
| echo "GITHUB_TAG=${{ github.event.inputs.tag }}" >> "$GITHUB_ENV" | ||||||||||||||||||
| # Check if input is a semantic version (e.g., 0.0.242) or a tag name (e.g., beta, scss-deprecation) | ||||||||||||||||||
| if [[ "${{ github.event.inputs.tag }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then | ||||||||||||||||||
| echo "IS_VERSION_INPUT=true" >> "$GITHUB_ENV" | ||||||||||||||||||
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | ||||||||||||||||||
| TAG="${{ github.event.inputs.tag }}" | ||||||||||||||||||
| REF="${{ github.event.inputs.branch }}" | ||||||||||||||||||
| else | ||||||||||||||||||
| echo "IS_VERSION_INPUT=false" >> "$GITHUB_ENV" | ||||||||||||||||||
| TAG="${GITHUB_REF#refs/tags/}" | ||||||||||||||||||
| REF="${{ github.event.release.target_commitish }}" | ||||||||||||||||||
| fi | ||||||||||||||||||
| - name: Set tag from release (automatic trigger) | ||||||||||||||||||
| if: github.event_name == 'release' | ||||||||||||||||||
| run: | | ||||||||||||||||||
| echo "GITHUB_TAG=${GITHUB_REF#refs/tags/}" >> "$GITHUB_ENV" | ||||||||||||||||||
| echo "IS_VERSION_INPUT=true" >> "$GITHUB_ENV" | ||||||||||||||||||
| - name: Checkout repository (manual trigger) | ||||||||||||||||||
| if: github.event_name == 'workflow_dispatch' | ||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||
| with: | ||||||||||||||||||
| ref: ${{ github.event.inputs.branch }} | ||||||||||||||||||
| token: ${{secrets.PAT_TOKEN}} | ||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||
| - name: Checkout repository (automatic release) | ||||||||||||||||||
| if: github.event_name == 'release' | ||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||
| echo "GITHUB_TAG=$TAG" >> "$GITHUB_ENV" | ||||||||||||||||||
| echo "CHECKOUT_REF=$REF" >> "$GITHUB_ENV" | ||||||||||||||||||
| [[ "$TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]] && echo "IS_VERSION_INPUT=true" >> "$GITHUB_ENV" || echo "IS_VERSION_INPUT=false" >> "$GITHUB_ENV" | ||||||||||||||||||
|
|
||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||
| with: | ||||||||||||||||||
| ref: ${{ github.event.release.target_commitish }} | ||||||||||||||||||
| token: ${{secrets.PAT_TOKEN}} | ||||||||||||||||||
| ref: ${{ env.CHECKOUT_REF }} | ||||||||||||||||||
| token: ${{ secrets.PAT_TOKEN }} | ||||||||||||||||||
| fetch-depth: 0 | ||||||||||||||||||
| - name: Set up Git | ||||||||||||||||||
| run: | | ||||||||||||||||||
| git config user.email "actions@clickhouse.com" | ||||||||||||||||||
| git config user.name "GitHub Actions" | ||||||||||||||||||
| - name: Bump package version (for version inputs) | ||||||||||||||||||
| if: ${{ env.IS_VERSION_INPUT == 'true' }} | ||||||||||||||||||
| run: | | ||||||||||||||||||
| npm pkg set version=$GITHUB_TAG | ||||||||||||||||||
| - name: Generate prerelease version (for tag inputs) | ||||||||||||||||||
| if: ${{ env.IS_VERSION_INPUT == 'false' }} | ||||||||||||||||||
|
|
||||||||||||||||||
| - name: Set package version | ||||||||||||||||||
| run: | | ||||||||||||||||||
| # Get current version from package.json | ||||||||||||||||||
| CURRENT_VERSION=$(node -p "require('./package.json').version") | ||||||||||||||||||
| # Extract base version (remove any existing prerelease suffix) | ||||||||||||||||||
| BASE_VERSION=$(echo $CURRENT_VERSION | cut -d'-' -f1) | ||||||||||||||||||
| # Generate prerelease version: base-tagname.0 | ||||||||||||||||||
| NEW_VERSION="${BASE_VERSION}-${GITHUB_TAG}.0" | ||||||||||||||||||
| echo "Generated prerelease version: $NEW_VERSION" | ||||||||||||||||||
| npm pkg set version=$NEW_VERSION --no-git-tag-version | ||||||||||||||||||
| if [[ "$IS_VERSION_INPUT" == "true" ]]; then | ||||||||||||||||||
| npm pkg set version=$GITHUB_TAG | ||||||||||||||||||
| else | ||||||||||||||||||
| LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | ||||||||||||||||||
| IFS='.' read -r MAJOR MINOR PATCH <<< "${LAST_TAG#v}" | ||||||||||||||||||
| BASE_VERSION="$MAJOR.$MINOR.$((PATCH + 1))" | ||||||||||||||||||
|
|
||||||||||||||||||
| LATEST_VERSION=$(npm view @clickhouse/click-ui@${GITHUB_TAG} version 2>/dev/null || echo "") | ||||||||||||||||||
|
||||||||||||||||||
| LATEST_VERSION=$(npm view @clickhouse/click-ui@${GITHUB_TAG} version 2>/dev/null || echo "") | |
| PACKAGE_NAME=$(node -p "require('./package.json').name") | |
| LATEST_VERSION=$(npm view "${PACKAGE_NAME}@${GITHUB_TAG}" version 2>/dev/null || echo "") |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NPM_TAG logic is incorrect when IS_VERSION_INPUT is false. For prerelease tags like 'beta', NPM_TAG will be set to the tag name (e.g., 'beta'), but for version inputs containing 'beta' (e.g., '0.0.246-beta.1'), it will also set NPM_TAG to the full version string instead of just 'beta'. The condition should be: if IS_VERSION_INPUT is false, use GITHUB_TAG as the npm tag; if IS_VERSION_INPUT is true and contains beta/alpha/rc, use 'beta' (not the full version); otherwise use 'latest'.
| [[ "$IS_VERSION_INPUT" == "false" || "$GITHUB_TAG" =~ (beta|alpha|rc) ]] && NPM_TAG="$GITHUB_TAG" || NPM_TAG="latest" | |
| if [[ "$IS_VERSION_INPUT" == "false" ]]; then | |
| NPM_TAG="$GITHUB_TAG" | |
| elif [[ "$GITHUB_TAG" =~ (beta|alpha|rc) ]]; then | |
| NPM_TAG="beta" | |
| else | |
| NPM_TAG="latest" | |
| fi |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The || true silently ignores all errors including genuine failures like network issues or permission problems. Consider making the tag push conditional with a proper if statement instead of using || true to mask failures.
| [[ "${{ github.event_name }}" == "workflow_dispatch" ]] && git tag $GITHUB_TAG && git push origin $GITHUB_TAG || true | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| if ! git tag "$GITHUB_TAG"; then | |
| echo "::warning::Failed to create git tag $GITHUB_TAG" | |
| elif ! git push origin "$GITHUB_TAG"; then | |
| echo "::warning::Failed to push git tag $GITHUB_TAG" | |
| fi | |
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PATCH extraction will fail if LAST_TAG contains a prerelease suffix (e.g., 'v0.0.246-beta.1'). The code should strip any prerelease suffix before parsing the version components, similar to how it's done on line 56 for LATEST_VERSION.