Skip to content

Commit

Permalink
Merge pull request #53 from IBM/release
Browse files Browse the repository at this point in the history
Release when a new tag is pushed
  • Loading branch information
dhruv5995 authored Nov 27, 2023
2 parents e54d403 + e85f3db commit 5a398c0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
name: Upload Python Package

on:
release:
types: [published]
push:
tags:
- "0.*"

permissions:
contents: read
Expand Down
5 changes: 4 additions & 1 deletion mlflow_watsonml/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from mlflow_watsonml.deploy import WatsonMLDeploymentClient
# THIS IS AN AUTOMATICALLY GENERATED FILE
# DO NOT EDIT IT SINCE YOUR CHANGES WILL
# BE LOST
__version__ = '0.11.2'
2 changes: 1 addition & 1 deletion mlflow_watsonml/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.11.1"
__version__ = "0.11.4"
37 changes: 37 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

VERSION=$1
ROOT="$( cd "$(dirname "$0")" ; pwd -P )"

if [ -z $VERSION ]; then
echo "usage: bash release <version>"
exit
fi

git checkout mlflow_watsonml/__init__.py
current_branch=$(git symbolic-ref --short HEAD 2>/dev/null)

if [ "$current_branch" != "main" ]; then
echo "Error: Branch must be 'main'. Current branch is '$current_branch'."
exit 1
fi

if ! git diff-index --quiet HEAD --; then echo "can't create release, you have uncommitted files"; exit; fi
if git status --porcelain 2>/dev/null | egrep "^ M|??"; then echo "Can't create release, you have uncommitted or untracked files"; exit; fi

# make sure this tag is in our setup.py
if ! grep "__version__ = \"$VERSION\"" mlflow_watsonml/_version.py; then "$VERSION does not match that listed in mlflow_watsonml/_version.py"; exit ; fi

echo creating mlflow_watsonml release $VERSION
echo "# THIS IS AN AUTOMATICALLY GENERATED FILE" > mlflow_watsonml/__init__.py
echo "# DO NOT EDIT IT SINCE YOUR CHANGES WILL" >> mlflow_watsonml/__init__.py
echo "# BE LOST" >> mlflow_watsonml/__init__.py
echo "__version__ = '$VERSION'" >> mlflow_watsonml/__init__.py

git commit -m"release $VERSION" mlflow_watsonml/__init__.py

cd $ROOT
echo "creating tag and pushing"
git tag -a $VERSION -m"new release" \
&& git push origin $VERSION \
&& git push

0 comments on commit 5a398c0

Please sign in to comment.