diff --git a/.github/workflows/shared-build-and-deploy.yml b/.github/workflows/shared-build-and-deploy.yml index 7d94b14f..1b0309dd 100644 --- a/.github/workflows/shared-build-and-deploy.yml +++ b/.github/workflows/shared-build-and-deploy.yml @@ -27,6 +27,22 @@ jobs: python -m pip install --upgrade pip pip install setuptools wheel twine + - name: Resolve Branch for the Tagged Commit + id: resolve-branch + if: ${{ inputs.tag == 'beta' || inputs.tag == 'public' }} + run: | + TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }}) + + BRANCH_NAME=$(git branch -r --contains $TAG_COMMIT | grep -o 'origin/.*' | sed 's|origin/||' | head -n 1) + + if [ -z "$BRANCH_NAME" ]; then + echo "Error: Could not resolve branch for the tag." + exit 1 + fi + + echo "Resolved Branch Name: $BRANCH_NAME" + echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV + - name: Get Previous tag id: previoustag uses: WyriHaximus/github-action-get-previous-tag@v1 @@ -43,23 +59,27 @@ jobs: fi - name: Commit changes - if: ${{ inputs.tag == 'internal' || inputs.tag == 'public' }} run: | git config user.name "${{ github.actor }}" git config user.email "${{ github.actor }}@users.noreply.github.com" + + if [[ "${{ inputs.tag }}" == "beta" || "${{ inputs.tag }}" == "public" ]]; then + git checkout ${{ env.branch_name }} + fi + git add setup.py git add skyflow/utils/_version.py - if [ "${{ inputs.tag }}" = "internal" ]; then + if [[ "${{ inputs.tag }}" == "internal" ]]; then VERSION="${{ steps.previoustag.outputs.tag }}.dev0+$(git rev-parse --short $GITHUB_SHA)" COMMIT_MESSAGE="[AUTOMATED] Private Release $VERSION" git commit -m "$COMMIT_MESSAGE" git push origin ${{ github.ref_name }} -f fi - if [ "${{ inputs.tag }}" = "public" ]; then + if [[ "${{ inputs.tag }}" == "beta" || "${{ inputs.tag }}" == "public" ]]; then COMMIT_MESSAGE="[AUTOMATED] Public Release - ${{ steps.previoustag.outputs.tag }}" git commit -m "$COMMIT_MESSAGE" - git push origin + git push origin ${{ env.branch_name }} fi - name: Build and Publish Package