From cb0c1aceb294bf0bb5fde86f2f4873197c9aed42 Mon Sep 17 00:00:00 2001 From: Guy Smoilovsky Date: Thu, 16 Jul 2026 11:05:22 +0300 Subject: [PATCH 1/2] Add manual-dispatch release workflow --- .github/workflows/release.yml | 113 ++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..9f515317 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,113 @@ +name: Release + +on: + workflow_dispatch: + inputs: + bump: + description: "Version bump type (ignored if explicit_version is set)" + required: true + type: choice + default: patch + options: + - patch + - minor + - major + explicit_version: + description: "Explicit version to release, e.g. 1.2.3 (overrides bump)" + required: false + type: string + release_title_suffix: + description: "Optional summary appended to the release title, e.g. \"- COCO annotation support\"" + required: false + type: string + draft: + description: "Create the GitHub release as a draft instead of publishing immediately (skips PyPI publish until you hit Publish)" + required: false + type: boolean + default: false + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Check out main + uses: actions/checkout@v4 + with: + ref: main + fetch-depth: 0 + + - name: Compute new version + id: version + env: + BUMP: ${{ inputs.bump }} + EXPLICIT_VERSION: ${{ inputs.explicit_version }} + run: | + set -euo pipefail + current=$(sed -n 's/^__version__ = "\(.*\)"/\1/p' dagshub/__init__.py) + if [ -z "$current" ]; then + echo "Could not find __version__ in dagshub/__init__.py" >&2 + exit 1 + fi + + if [ -n "$EXPLICIT_VERSION" ]; then + if ! [[ "$EXPLICIT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "explicit_version '$EXPLICIT_VERSION' is not a valid X.Y.Z semver" >&2 + exit 1 + fi + new="$EXPLICIT_VERSION" + else + IFS='.' read -r major minor patch <<< "$current" + case "$BUMP" in + major) new="$((major + 1)).0.0" ;; + minor) new="${major}.$((minor + 1)).0" ;; + patch) new="${major}.${minor}.$((patch + 1))" ;; + *) echo "Unknown bump type '$BUMP'" >&2; exit 1 ;; + esac + fi + + if [ "$new" = "$current" ]; then + echo "New version '$new' is the same as the current version" >&2 + exit 1 + fi + + if git rev-parse "$new" >/dev/null 2>&1; then + echo "Tag '$new' already exists" >&2 + exit 1 + fi + + echo "current=$current" >> "$GITHUB_OUTPUT" + echo "new=$new" >> "$GITHUB_OUTPUT" + + - name: Bump version and commit to main + env: + NEW_VERSION: ${{ steps.version.outputs.new }} + run: | + set -euo pipefail + sed -i "s/^__version__ = \".*\"/__version__ = \"${NEW_VERSION}\"/" dagshub/__init__.py + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add dagshub/__init__.py + git commit -m "${NEW_VERSION} version bump" + git push origin HEAD:main + + - name: Create GitHub release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NEW_VERSION: ${{ steps.version.outputs.new }} + TITLE_SUFFIX: ${{ inputs.release_title_suffix }} + DRAFT: ${{ inputs.draft }} + run: | + set -euo pipefail + title="${NEW_VERSION} ${TITLE_SUFFIX}" + draft_flag=() + if [ "$DRAFT" = "true" ]; then + draft_flag=(--draft) + fi + gh release create "$NEW_VERSION" \ + --target main \ + --title "$title" \ + --generate-notes \ + "${draft_flag[@]}" From 61558299097815f255d764c826af19c960f66ccc Mon Sep 17 00:00:00 2001 From: Guy Smoilovsky Date: Thu, 16 Jul 2026 11:15:26 +0300 Subject: [PATCH 2/2] Pin release target to the exact bump commit SHA --- .github/workflows/release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f515317..35cc473f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,6 +82,7 @@ jobs: echo "new=$new" >> "$GITHUB_OUTPUT" - name: Bump version and commit to main + id: commit env: NEW_VERSION: ${{ steps.version.outputs.new }} run: | @@ -92,6 +93,7 @@ jobs: git add dagshub/__init__.py git commit -m "${NEW_VERSION} version bump" git push origin HEAD:main + echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" - name: Create GitHub release env: @@ -99,6 +101,7 @@ jobs: NEW_VERSION: ${{ steps.version.outputs.new }} TITLE_SUFFIX: ${{ inputs.release_title_suffix }} DRAFT: ${{ inputs.draft }} + TARGET_SHA: ${{ steps.commit.outputs.sha }} run: | set -euo pipefail title="${NEW_VERSION} ${TITLE_SUFFIX}" @@ -107,7 +110,7 @@ jobs: draft_flag=(--draft) fi gh release create "$NEW_VERSION" \ - --target main \ + --target "$TARGET_SHA" \ --title "$title" \ --generate-notes \ "${draft_flag[@]}"