Skip to content

Commit

Permalink
Add platform info in file name.
Browse files Browse the repository at this point in the history
  • Loading branch information
ogra committed Jul 31, 2024
1 parent a87f2ea commit edd33d7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/nightly-release-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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"
30 changes: 28 additions & 2 deletions toolchain/install/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit edd33d7

Please sign in to comment.