From 4695d14b5d6445339254b5016ec5dcc3d1e1618a Mon Sep 17 00:00:00 2001 From: tea artist Date: Fri, 26 Jul 2024 16:56:33 +0800 Subject: [PATCH 1/8] test: tag --- .github/workflows/docker-push.yml | 2 +- scripts/build-image.mjs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index f9fe7ad0ff..8966fa237e 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -3,7 +3,7 @@ name: Build and Push to Docker Registry on: push: branches: - - develop + - fix/transaction tags: - 'v*' paths: diff --git a/scripts/build-image.mjs b/scripts/build-image.mjs index 28c6afe2ac..d4e3c951c1 100755 --- a/scripts/build-image.mjs +++ b/scripts/build-image.mjs @@ -35,6 +35,10 @@ const getSemver = async () => { const runNumber = env.GITHUB_RUN_NUMBER; const sha = env.GITHUB_SHA.substring(0, 7); + console.log('refType: ', refType); + console.log('runNumber: ', runNumber); + console.log('sha: ', sha); + switch (refType) { case 'branch': semver = `${version}-alpha+build.${runNumber}.sha-${sha}`; @@ -44,7 +48,7 @@ const getSemver = async () => { break; } } - + console.log('semver: ', semver); return semver; }; From 4c8364b6463c31872e2533630fd06e029d5d10d8 Mon Sep 17 00:00:00 2001 From: tea artist Date: Fri, 26 Jul 2024 16:58:53 +0800 Subject: [PATCH 2/8] test: only output --- scripts/build-image.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/build-image.mjs b/scripts/build-image.mjs index d4e3c951c1..5577a979d5 100755 --- a/scripts/build-image.mjs +++ b/scripts/build-image.mjs @@ -124,4 +124,5 @@ if (push) { command.push('.'); command.push('--progress=plain'); -await $`${command}`; +// await $`${command}`; +console.log(command.join(' ')); From 8d9b83a812624157b2cbb1a59a45f2b01f784e61 Mon Sep 17 00:00:00 2001 From: tea artist Date: Fri, 26 Jul 2024 17:00:31 +0800 Subject: [PATCH 3/8] chore: track change --- .github/workflows/docker-push.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index 8966fa237e..09b03b6d61 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -3,7 +3,7 @@ name: Build and Push to Docker Registry on: push: branches: - - fix/transaction + - build/tag tags: - 'v*' paths: @@ -11,6 +11,7 @@ on: - 'apps/nextjs-app/**' - 'packages/core/**' - 'packages/sdk/**' + - '.github/**' jobs: build-push: From cd98f17c7ee300965375483333960b6258d3e44d Mon Sep 17 00:00:00 2001 From: tea artist Date: Fri, 26 Jul 2024 18:47:28 +0800 Subject: [PATCH 4/8] chore: track change --- .github/workflows/docker-push.yml | 14 -------------- scripts/build-image.mjs | 15 +++++++-------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index 09b03b6d61..e81b06b6b5 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -58,19 +58,6 @@ jobs: - name: ⚙️ Install zx run: npm install -g zx - - name: ⚙️ Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - registry.cn-shenzhen.aliyuncs.com/teable/${{ matrix.image }} - ghcr.io/teableio/${{ matrix.image }} - docker.io/teableio/${{ matrix.image }} - tags: | - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - # set latest tag for default branch - type=raw,value=latest,enable={{is_default_branch}} - name: ⚙️ Set up QEMU uses: docker/setup-qemu-action@v3 - name: ⚙️ Set up Docker Buildx @@ -79,6 +66,5 @@ jobs: run: | zx scripts/build-image.mjs --file=dockers/teable/${{ matrix.file }} \ --build-arg="ENABLE_CSP=false" \ - --tag="${{ steps.meta.outputs.tags }}" \ --platforms="linux/amd64,linux/arm64" \ --push diff --git a/scripts/build-image.mjs b/scripts/build-image.mjs index 5577a979d5..428804815e 100755 --- a/scripts/build-image.mjs +++ b/scripts/build-image.mjs @@ -80,8 +80,6 @@ const { 'build-arg': buildArg, 'cache-from': cacheFromArg, 'cache-to': cacheToArg, - tag, - 'tag-suffix': tagSuffix, platforms: platformsArg, push: pushArg, } = argv; @@ -89,14 +87,13 @@ const { const buildArgs = toArray(buildArg); const cacheFrom = toArray(cacheFromArg); const cacheTo = toArray(cacheToArg); -const tags = toArray(tag, false, true); const platforms = toArray(platformsArg, true); const push = toBoolean(pushArg); const command = ['docker', 'buildx', 'build']; -// BUILD_VERSION - this is a default behavior -command.push('--build-arg', `BUILD_VERSION=${await getSemver()}`); +const semver = await getSemver(); +command.push('--build-arg', `BUILD_VERSION=${semver}`); await asyncForEach(buildArgs, async (buildArg) => { command.push('--build-arg', buildArg); @@ -113,9 +110,11 @@ if (file) { if (platforms.length > 0) { command.push('--platform', platforms.join(',')); } -await asyncForEach(tags, async (tag) => { - command.push('--tag', `${tag}${tagSuffix ?? ''}`); -}); + +// 使用 package.json 中的版本号作为标签,并添加 latest 标签 +const imageName = 'your-image-name'; // 请替换为您的镜像名称 +command.push('--tag', `${imageName}:${semver}`); +command.push('--tag', `${imageName}:latest`); if (push) { command.push('--push'); From 9ff969943b04bb7013edfa2a39ac1580a363599b Mon Sep 17 00:00:00 2001 From: tea artist Date: Fri, 26 Jul 2024 19:03:31 +0800 Subject: [PATCH 5/8] build: test --- .github/workflows/docker-push.yml | 12 ++++++++++++ scripts/build-image.mjs | 14 +++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index e81b06b6b5..7418623030 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -58,6 +58,17 @@ jobs: - name: ⚙️ Install zx run: npm install -g zx + - name: ⚙️ Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + registry.cn-shenzhen.aliyuncs.com/teable/${{ matrix.image }} + ghcr.io/teableio/${{ matrix.image }} + docker.io/teableio/${{ matrix.image }} + tags: | + type=raw,value=latest + - name: ⚙️ Set up QEMU uses: docker/setup-qemu-action@v3 - name: ⚙️ Set up Docker Buildx @@ -66,5 +77,6 @@ jobs: run: | zx scripts/build-image.mjs --file=dockers/teable/${{ matrix.file }} \ --build-arg="ENABLE_CSP=false" \ + --tag="${{ steps.meta.outputs.tags }}" \ --platforms="linux/amd64,linux/arm64" \ --push diff --git a/scripts/build-image.mjs b/scripts/build-image.mjs index 428804815e..ba49bf03fd 100755 --- a/scripts/build-image.mjs +++ b/scripts/build-image.mjs @@ -80,6 +80,8 @@ const { 'build-arg': buildArg, 'cache-from': cacheFromArg, 'cache-to': cacheToArg, + tag, + 'tag-suffix': tagSuffix, platforms: platformsArg, push: pushArg, } = argv; @@ -87,11 +89,13 @@ const { const buildArgs = toArray(buildArg); const cacheFrom = toArray(cacheFromArg); const cacheTo = toArray(cacheToArg); +const tags = toArray(tag, false, true); const platforms = toArray(platformsArg, true); const push = toBoolean(pushArg); const command = ['docker', 'buildx', 'build']; +// BUILD_VERSION - this is a default behavior const semver = await getSemver(); command.push('--build-arg', `BUILD_VERSION=${semver}`); @@ -110,11 +114,11 @@ if (file) { if (platforms.length > 0) { command.push('--platform', platforms.join(',')); } - -// 使用 package.json 中的版本号作为标签,并添加 latest 标签 -const imageName = 'your-image-name'; // 请替换为您的镜像名称 -command.push('--tag', `${imageName}:${semver}`); -command.push('--tag', `${imageName}:latest`); +await asyncForEach(tags, async (tag) => { + command.push('--tag', `${tag}${tagSuffix ?? ''}`); + // 添加新的 tag,使用 semver + command.push('--tag', `${tag}:${semver}${tagSuffix ?? ''}`); +}); if (push) { command.push('--push'); From 007a8d66052f5e28439850e5b9ebd74d07515409 Mon Sep 17 00:00:00 2001 From: tea artist Date: Fri, 26 Jul 2024 19:06:02 +0800 Subject: [PATCH 6/8] build: test --- scripts/build-image.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/build-image.mjs b/scripts/build-image.mjs index ba49bf03fd..e71ba62fba 100755 --- a/scripts/build-image.mjs +++ b/scripts/build-image.mjs @@ -114,10 +114,10 @@ if (file) { if (platforms.length > 0) { command.push('--platform', platforms.join(',')); } -await asyncForEach(tags, async (tag) => { - command.push('--tag', `${tag}${tagSuffix ?? ''}`); - // 添加新的 tag,使用 semver - command.push('--tag', `${tag}:${semver}${tagSuffix ?? ''}`); +await asyncForEach(tags, async (fullName) => { + const [image, tag] = fullName.split(':'); + command.push('--tag', `${image}:${tag}${tagSuffix ?? ''}`); + command.push('--tag', `${image}:${semver}`); }); if (push) { From 05319656cc81131b6728c57d0feb6d7ea7234479 Mon Sep 17 00:00:00 2001 From: tea artist Date: Fri, 26 Jul 2024 19:07:15 +0800 Subject: [PATCH 7/8] build: test --- .github/workflows/docker-push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index 7418623030..59691883ba 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -12,6 +12,7 @@ on: - 'packages/core/**' - 'packages/sdk/**' - '.github/**' + - 'scripts/**' jobs: build-push: From cdb6d5da2f5ccbe3eba4fb64a190bbdf000d5c13 Mon Sep 17 00:00:00 2001 From: tea artist Date: Fri, 26 Jul 2024 19:12:21 +0800 Subject: [PATCH 8/8] build: tag docker with devlop merge --- .github/workflows/docker-push.yml | 2 +- scripts/build-image.mjs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index 59691883ba..15584a9f42 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -3,7 +3,7 @@ name: Build and Push to Docker Registry on: push: branches: - - build/tag + - develop tags: - 'v*' paths: diff --git a/scripts/build-image.mjs b/scripts/build-image.mjs index e71ba62fba..7f98044469 100755 --- a/scripts/build-image.mjs +++ b/scripts/build-image.mjs @@ -127,5 +127,4 @@ if (push) { command.push('.'); command.push('--progress=plain'); -// await $`${command}`; -console.log(command.join(' ')); +await $`${command}`;