From edd33d75b76f8a451ece80ef08e0325bcaaf1800 Mon Sep 17 00:00:00 2001 From: Toshiyuki Ogura Date: Wed, 31 Jul 2024 23:46:34 +0900 Subject: [PATCH] Add platform info in file name. --- .github/workflows/nightly-release-macos.yaml | 14 ++++++++- toolchain/install/BUILD | 30 ++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nightly-release-macos.yaml b/.github/workflows/nightly-release-macos.yaml index 52a1d898ec3a7..8ac773d602ff4 100644 --- a/.github/workflows/nightly-release-macos.yaml +++ b/.github/workflows/nightly-release-macos.yaml @@ -82,6 +82,18 @@ jobs: | cut -d' ' -f5 | cut -d'+' -f1) echo "release_version=$VERSION" >> $GITHUB_ENV + - name: Determine platform-specific file name + id: platform + run: | + if [[ "${{ matrix.arch }}" == "amd64" ]]; then + echo "PLATFORM_SUFFIX=macos-amd64" >> $GITHUB_ENV + elif [[ "${{ matrix.arch }}" == "arm64" ]]; then + echo "PLATFORM_SUFFIX=macos-arm64" >> $GITHUB_ENV + else + echo "Unsupported architecture: ${{ matrix.arch }}" + exit 1 + fi + - name: Create the release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -91,4 +103,4 @@ jobs: --generate-notes \ --prerelease \ v${{ env.release_version }} \ - "bazel-bin/toolchain/install/carbon_toolchain-${{ env.release_version }}.tar.gz" + "bazel-bin/toolchain/install/carbon_toolchain-${{ env.release_version }}-${{ env.PLATFORM_SUFFIX }}.tar.gz" diff --git a/toolchain/install/BUILD b/toolchain/install/BUILD index 996ec8a9385f9..b937a0eb3bee1 100644 --- a/toolchain/install/BUILD +++ b/toolchain/install/BUILD @@ -8,6 +8,7 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test") load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mklink", "strip_prefix") load("pkg_helpers.bzl", "pkg_naming_variables", "pkg_tar_and_test") load("symlink_filegroup.bzl", "symlink_filegroup") +load("@bazel_tools//tools/platforms:platforms.bzl", "host_platform") package(default_visibility = ["//visibility:public"]) @@ -205,11 +206,36 @@ pkg_naming_variables( # We build both a compressed and uncompressed tar file with the same code here. # This lets us use the tar file in testing as it is fast to create, but ship the # compressed version as a release. + +config_setting( + name = "macos_amd64", + constraint_values = [ + "@bazel_tools//platforms:osx", + "@bazel_tools//platforms:x86_64", + ], +) + +config_setting( + name = "macos_arm64", + constraint_values = [ + "@bazel_tools//platforms:osx", + "@bazel_tools//platforms:arm64", + ], +) + pkg_tar_and_test( srcs = [":packaging_files"], name_base = "carbon_toolchain", - package_dir = "carbon_toolchain-$(version)", - package_file_name_base = "carbon_toolchain-$(version)", + package_dir = select({ + ":macos_amd64": "carbon_toolchain-$(version)-macos-amd64", + ":macos_arm64": "carbon_toolchain-$(version)-macos-arm64", + "//conditions:default": "carbon_toolchain-$(version)", + }), + package_file_name_base = select({ + ":macos_amd64": "carbon_toolchain-$(version)-macos-amd64", + ":macos_arm64": "carbon_toolchain-$(version)-macos-arm64", + "//conditions:default": "carbon_toolchain-$(version)", + }), package_variables = ":packaging_variables", stamp = -1, # Allow `--stamp` builds to produce file timestamps. test_data = [