-
Notifications
You must be signed in to change notification settings - Fork 31
Add manual-dispatch release workflow #706
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| 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 | ||
| id: commit | ||
| 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 | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - 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 }} | ||
| TARGET_SHA: ${{ steps.commit.outputs.sha }} | ||
| 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 "$TARGET_SHA" \ | ||
| --title "$title" \ | ||
| --generate-notes \ | ||
| "${draft_flag[@]}" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.