From 2996b88cd16c9b2b523e7de9b4845494eb03002e Mon Sep 17 00:00:00 2001 From: Nick Hynes Date: Fri, 22 May 2026 20:45:57 +0800 Subject: [PATCH] publish release branches with npm series tag --- .github/workflows/publish.yaml | 27 +++++++++++++++++++-------- npm/release.mjs | 10 ++++++---- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 59b68c73..a256008f 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -4,6 +4,8 @@ on: push: branches: - main + - "v*.*.x" + workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -141,10 +143,10 @@ jobs: labels: | org.opencontainers.image.revision=${{ github.sha }} tags: | - ${{ steps.registry.outputs.image_registry }}/${{ matrix.image }}:main-${{ matrix.arch }} + ${{ steps.registry.outputs.image_registry }}/${{ matrix.image }}:${{ github.ref_name }}-${{ matrix.arch }} ${{ steps.registry.outputs.image_registry }}/${{ matrix.image }}:${{ github.sha }}-${{ matrix.arch }} - cache-from: type=gha,scope=refs/heads/main-${{ matrix.image }}-${{ matrix.arch }} - cache-to: type=gha,mode=max,scope=refs/heads/main-${{ matrix.image }}-${{ matrix.arch }} + cache-from: type=gha,scope=${{ github.ref }}-${{ matrix.image }}-${{ matrix.arch }} + cache-to: type=gha,mode=max,scope=${{ github.ref }}-${{ matrix.image }}-${{ matrix.arch }} merge-manifests: name: Create Multi-Arch Manifests @@ -193,7 +195,7 @@ jobs: run: | set -euo pipefail echo "version=${{ needs.resolved-version-tags.outputs.amber_cli_version }}" >> "$GITHUB_OUTPUT" - - name: Publish base multi-arch tags (main + sha) + - name: Publish base multi-arch tags (branch + sha) shell: bash run: | set -euo pipefail @@ -202,9 +204,9 @@ jobs: [ -z "$image" ] && continue docker buildx imagetools create \ --annotation "index:org.opencontainers.image.revision=${GITHUB_SHA}" \ - -t "${image}:main" \ - "${image}:main-amd64" \ - "${image}:main-arm64" + -t "${image}:${GITHUB_REF_NAME}" \ + "${image}:${GITHUB_REF_NAME}-amd64" \ + "${image}:${GITHUB_REF_NAME}-arm64" docker buildx imagetools create \ --annotation "index:org.opencontainers.image.revision=${GITHUB_SHA}" \ -t "${image}:${GITHUB_SHA}" \ @@ -574,11 +576,20 @@ jobs: run: | mkdir -p .tmp node npm/release.mjs spec > .tmp/npm-release-spec.json + + dist_tag="latest" + if [ "$GITHUB_REF_NAME" != "main" ]; then + version_series="${GITHUB_REF_NAME#v}" + version_series="${version_series%.x}" + dist_tag="series-${version_series}" + fi + node npm/release.mjs publish-release \ --spec .tmp/npm-release-spec.json \ --artifact-root .tmp/npm-binary-artifacts \ --out-dir .tmp/npm-packages \ - --version-floor "${{ needs.resolved-version-tags.outputs.amber_cli_version }}" + --version-floor "${{ needs.resolved-version-tags.outputs.amber_cli_version }}" \ + --dist-tag "$dist_tag" cli-artifacts: name: Build amber-cli artifacts (${{ matrix.platform }}) diff --git a/npm/release.mjs b/npm/release.mjs index a470eae8..a148d2b5 100644 --- a/npm/release.mjs +++ b/npm/release.mjs @@ -577,14 +577,14 @@ async function resolveRuntimePackageVersions({ spec, packageRoot, versionFloors } } -function npmPublish(dir) { - runCommand("npm", ["publish", "--access", "public", "--registry", NPM_REGISTRY], { +function npmPublish(dir, distTag) { + runCommand("npm", ["publish", "--access", "public", "--registry", NPM_REGISTRY, "--tag", distTag], { cwd: dir, env: process.env, }); } -async function publishPackages({ spec, packageRoot }) { +async function publishPackages({ spec, packageRoot, distTag }) { const packageDirs = spec.runtime_packages.flatMap((runtimePackage) => runtimePackagePublishDirs(runtimePackage, packageRoot), ); @@ -603,7 +603,7 @@ async function publishPackages({ spec, packageRoot }) { fail(`${packageJson.name}@${packageJson.version} already exists with different contents`); } - npmPublish(dir); + npmPublish(dir, distTag); } } @@ -668,6 +668,7 @@ async function publishRelease(args) { const spec = readSpec(args); const outDir = requireFlag(args, "--out-dir"); const versionFloor = requireFlag(args, "--version-floor"); + const distTag = requireFlag(args, "--dist-tag"); stagePackages({ spec, @@ -685,6 +686,7 @@ async function publishRelease(args) { await publishPackages({ spec, packageRoot: outDir, + distTag, }); }