Skip to content

Commit

Permalink
chore(ci): add version check
Browse files Browse the repository at this point in the history
  • Loading branch information
hexf00 committed Jun 11, 2024
1 parent 36b26fa commit 8844aa6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ jobs:
run: |
echo "value=$(make check_image_exists)" >> $GITHUB_OUTPUT
- name: block_if_image_exists
if: steps.check_image_exists.outputs.value == 'true'
run: echo "Image ${{ steps.stepGetImageTag.outputs.value }} already exists, skipping build, please manually trigger the deployment workflow with the existing tag"

- name: Build
run: |
pnpm typedoc
pnpm build
# if: steps.check_image_exists.outputs.value != 'true'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# if: steps.check_image_exists.outputs.value != 'true'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx
# if: steps.check_image_exists.outputs.value != 'true'

- name: Build and Push Docker Image
run: |
make push_image -e PUSH_TAG=${{ steps.stepGetImageTag.outputs.value }} -e BUILDER=${{ steps.buildx.outputs.name }}
# if: steps.check_image_exists.outputs.value != 'true'
3 changes: 3 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: 📤 Deploy Staging

on:
push:
branches:
- ci/version-check
workflow_dispatch:
inputs:
image-tag:
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ endif
$(CTR) run --rm -it -p 8001:80 $(image_tag)

.PHONY: get_image_tag
# The image version number consists of three parts
# 1. The short commit id of the current git repository
# 2. The version number in the package.json file
# 3. The short commit id of the univer repository
get_image_tag:
ifeq ($(UNIVER_CLONE_ROOT),)
$(error UNIVER_CLONE_ROOT is not set)
endif
$(eval IMAGE_TAG=$(shell cat $(UNIVER_CLONE_ROOT)/package.json | grep '"version":' | head -1 | awk -F '"' '{print $$4}'))
$(eval IMAGE_TAG=$(shell git rev-parse --short HEAD))
$(eval IMAGE_TAG=$(IMAGE_TAG)-$(shell cat $(UNIVER_CLONE_ROOT)/package.json | grep '"version":' | head -1 | awk -F '"' '{print $$4}'))
$(eval IMAGE_TAG=$(IMAGE_TAG)-$(shell git -C $(UNIVER_CLONE_ROOT)/ rev-parse --short HEAD))

.PHONY: echo_image_tag
Expand Down

0 comments on commit 8844aa6

Please sign in to comment.