From ce9e0c65c902854c181abe65acc5d6afd3c1f93d Mon Sep 17 00:00:00 2001 From: Seer Date: Fri, 30 Aug 2024 21:25:14 +0800 Subject: [PATCH] build: reset pr pipeline docker tag --- .github/workflows/pr-pipeline.yaml | 22 +++++++++++----------- build/Dockerfile | 1 - version | 1 - 3 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 version diff --git a/.github/workflows/pr-pipeline.yaml b/.github/workflows/pr-pipeline.yaml index d80f309..0f3d7ab 100644 --- a/.github/workflows/pr-pipeline.yaml +++ b/.github/workflows/pr-pipeline.yaml @@ -43,15 +43,15 @@ jobs: - name: Check out code uses: actions/checkout@v4 - - name: Read version from file - id: get_version + - name: Setup envs + id: setup_envs run: | - ls -la - echo "VERSION=$(cat version)" >> $GITHUB_ENV + VERSION=$(git tag --merged $BRANCH_NAME --sort=-v:refname | head -n 1) + if [ -z "$VERSION" ]; then + VERSION="3.18.0" + fi + echo "VERSION=$VERSION" >> $GITHUB_ENV - - name: Get branch name - id: get_branch - run: | if [ "${{ github.event_name }}" == "pull_request" ]; then BRANCH_NAME=${{ github.head_ref }} else @@ -61,9 +61,9 @@ jobs: SANITIZED_BRANCH_NAME=$(echo "$BRANCH_NAME" | tr -cs '[:alnum:]' '-' | sed 's/-*$//' | tr '[:upper:]' '[:lower:]') echo "BRANCH_NAME=$SANITIZED_BRANCH_NAME" >> $GITHUB_ENV - - name: Get short commit SHA - id: get_commit - run: echo "COMMIT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV + echo "TIMESTAMP=$(date -u +'%y%m%d%H%M')" >> $GITHUB_ENV + + echo "COMMIT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -87,6 +87,6 @@ jobs: file: ./build/Dockerfile context: . push: true - tags: ghcr.io/${{ github.repository }}:${{ env.VERSION }}-${{ env.BRANCH_NAME }}-${{ env.COMMIT_SHA }} + tags: ghcr.io/${{ github.repository }}:${{ env.VERSION }}-${{ env.BRANCH_NAME }}-${{ env.TIMESTAMP }}.${{ env.COMMIT_SHA }} platforms: linux/amd64,linux/arm64 diff --git a/build/Dockerfile b/build/Dockerfile index 8341f88..925e162 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -17,7 +17,6 @@ FROM $BUILDER_IMAGE AS builder WORKDIR /workspace # Copy the go source -COPY version version COPY api/ api/ COPY cmd/ cmd/ COPY internal/ internal/ diff --git a/version b/version deleted file mode 100644 index c5b45eb..0000000 --- a/version +++ /dev/null @@ -1 +0,0 @@ -3.18.0