44 workflow_dispatch :
55 inputs :
66 release_tag :
7- description : Existing stable Workspace release tag in vX.Y.Z form
7+ description : Optional existing stable Workspace release tag in vX.Y.Z form
88 type : string
9- required : true
9+ required : false
1010
1111 environment :
1212 description : ' Environment to run deploy'
3838 name : BuildDockerImage
3939 runs-on : ${{ inputs.runner-name == 'github-runner' && 'ubuntu-latest' || inputs.runner-name }}
4040 environment : ${{ inputs.environment }}
41+ outputs :
42+ image_tag : ${{ steps.release.outputs.image_tag }}
4143 env :
4244 GH_ACCESS_TOKEN : ${{ secrets.GH_TOKEN }}
4345 CR : univer-acr-registry.cn-shenzhen.cr.aliyuncs.com
@@ -49,29 +51,35 @@ jobs:
4951 with :
5052 fetch-depth : 0
5153 persist-credentials : false
52- ref : refs/tags/${{ inputs.release_tag }}
54+ ref : ${{ inputs.release_tag == '' && github.sha || format(' refs/tags/{0}', inputs.release_tag) }}
5355
54- - name : Validate release tag
56+ - name : Resolve deployment source
5557 id : release
5658 shell : bash
5759 env :
5860 BASE_BRANCH : ${{ github.event.repository.default_branch }}
61+ DISPATCH_SHA : ${{ github.sha }}
5962 RELEASE_TAG : ${{ inputs.release_tag }}
6063 run : |
6164 set -euo pipefail
62- if [[ ! "$RELEASE_TAG" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
63- echo "release_tag must use stable vX.Y.Z form" >&2
64- exit 1
65- fi
66- if [[ "$(git rev-parse "refs/tags/$RELEASE_TAG^{commit}")" != "$(git rev-parse HEAD)" ]]; then
67- echo "Checkout does not match release tag $RELEASE_TAG" >&2
68- exit 1
69- fi
70- if ! git merge-base --is-ancestor HEAD "refs/remotes/origin/$BASE_BRANCH"; then
71- echo "Release tag commit must be contained in origin/$BASE_BRANCH" >&2
72- exit 1
65+ if [[ -n "$RELEASE_TAG" ]]; then
66+ if [[ ! "$RELEASE_TAG" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
67+ echo "release_tag must use stable vX.Y.Z form" >&2
68+ exit 1
69+ fi
70+ if [[ "$(git rev-parse "refs/tags/$RELEASE_TAG^{commit}")" != "$(git rev-parse HEAD)" ]]; then
71+ echo "Checkout does not match release tag $RELEASE_TAG" >&2
72+ exit 1
73+ fi
74+ if ! git merge-base --is-ancestor HEAD "refs/remotes/origin/$BASE_BRANCH"; then
75+ echo "Release tag commit must be contained in origin/$BASE_BRANCH" >&2
76+ exit 1
77+ fi
78+ IMAGE_TAG="$RELEASE_TAG"
79+ else
80+ IMAGE_TAG="sha-$DISPATCH_SHA"
7381 fi
74- echo "image_tag=$RELEASE_TAG " >> "$GITHUB_OUTPUT"
82+ echo "image_tag=$IMAGE_TAG " >> "$GITHUB_OUTPUT"
7583
7684 - uses : ./.github/actions/setup
7785 id : setup
8290 - name : Build and Push Image
8391 env :
8492 IMAGE_TAG : ${{ steps.release.outputs.image_tag }}
93+ UNIVER_WORKSPACE_BROWSER_LICENSE : ${{ secrets.UNIVER_WORKSPACE_BROWSER_LICENSE }}
8594 run : |
8695 make push_image "IMAGE_TAG=$IMAGE_TAG" "CR=$CR"
8796
@@ -92,12 +101,8 @@ jobs:
92101 environment : ${{ inputs.environment }}
93102 env :
94103 CR : univer-acr-registry.cn-shenzhen.cr.aliyuncs.com
104+ IMAGE_TAG : ${{ needs.build-docker-image.outputs.image_tag }}
95105 steps :
96- - name : Set IMAGE_TAG environment variable
97- env :
98- RELEASE_TAG : ${{ inputs.release_tag }}
99- run : echo "IMAGE_TAG=$RELEASE_TAG" >> "$GITHUB_ENV"
100-
101106 - name : Set FEATURE environment variable
102107 if : ${{ startsWith(inputs.environment, 'feature') }}
103108 run : echo "FEATURE=$(echo ${GITHUB_REF#refs/heads/feat/})" >> "$GITHUB_ENV"
0 commit comments