Skip to content

Commit

Permalink
[GIT] initial BCR infra (#37)
Browse files Browse the repository at this point in the history
* [GIT] initial BCR infra

* [GIT] fix release prep
  • Loading branch information
hexdae committed Mar 28, 2024
1 parent 6281ff5 commit 3288190
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .bcr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Bazel Central Registry

When the ruleset is released, we want it to be published to the
Bazel Central Registry automatically:
<https://registry.bazel.build>

This folder contains configuration files to automate the publish step.
See <https://github.com/bazel-contrib/publish-to-bcr/blob/main/templates/README.md>
for authoritative documentation about these files.
6 changes: 6 additions & 0 deletions .bcr/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# See https://github.com/bazel-contrib/publish-to-bcr#a-note-on-release-automation
# for guidance about whether to uncomment this section:
#
# fixedReleaser:
# login: my_github_handle
# email: me@my.org
12 changes: 12 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"homepage": "https://github.com/hexdae/bazel_arm_toolchains",
"maintainers": {
"name": "Davide Asnaghi",
"github": "hexdae"
},
"repository": [
"github:hexdae/bazel_arm_toolchains"
],
"versions": [],
"yanked_versions": {}
}
12 changes: 12 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
bcr_test_module:
module_path: "examples/bzlmod"
matrix:
platform: ["debian10", "macos", "ubuntu2004"]
bazel: ["7.x", "6.x"]
tasks:
run_tests:
name: "Run test module"
platform: ${{ platform }}
bazel: ${{ bazel }}
test_targets:
- "//..."
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "**leave this alone**",
"strip_prefix": "{REPO}-{VERSION}",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
}
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# In code review, collapse generated files
MODULE.bazel.lock linguist-generated=true

#################################
# Configuration for 'git archive'
# See https://git-scm.com/docs/git-archive#ATTRIBUTES

# Don't include examples in the distribution artifact, to reduce size.
# You may want to add additional exclusions for folders or files that users don't need.
examples export-ignore
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Cut a release whenever a new tag is pushed to the repo.
# You should use an annotated tag, like `git tag -a v1.2.3`
# and put the release notes into the commit message for the tag.
name: Release

on:
push:
tags:
- "v*.*.*"

jobs:
release:
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v6
with:
release_files: bazel-arm-none-eabi-*.tar.gz
54 changes: 54 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail

# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
# The prefix is chosen to match what GitHub generates for source archives
# This guarantees that users can easily switch from a released artifact to a source archive
# with minimal differences in their code (e.g. strip_prefix remains the same)
PREFIX="bazel-arm-none-eabi-${TAG:1}"
ARCHIVE="bazel-arm-none-eabi-$TAG.tar.gz"

# NB: configuration for 'git archive' is in /.gitattributes
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat << EOF
## Using Bzlmod with Bazel 6 or greater
1. (Bazel 6 only) Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
2. Add to your \`MODULE.bazel\` file:
\`\`\`starlark
bazel_dep(name = "arm_gnu_toolchain", version = "${TAG:1}")
# Toolchains: arm-none-eabi
arm_toolchain = use_extension("@arm_gnu_toolchain//:extensions.bzl", "arm_toolchain")
arm_toolchain.arm_none_eabi(version = "13.2.1")
use_repo(
arm_toolchain,
"arm_none_eabi",
"arm_none_eabi_darwin_arm64",
"arm_none_eabi_darwin_x86_64",
"arm_none_eabi_linux_aarch64",
"arm_none_eabi_linux_x86_64",
"arm_none_eabi_windows_x86_64",
)
register_toolchains("@arm_none_eabi//toolchain:all")
# Toolchains: arm-none-linux-gnueabihf
arm_toolchain.arm_none_linux_gnueabihf(version = "13.2.1")
use_repo(
arm_toolchain,
"arm_none_linux_gnueabihf",
"arm_none_linux_gnueabihf_linux_aarch64",
"arm_none_linux_gnueabihf_linux_x86_64",
"arm_none_linux_gnueabihf_windows_x86_64",
)
register_toolchains("@arm_none_linux_gnueabihf//toolchain:all")
\`\`\`
EOF

0 comments on commit 3288190

Please sign in to comment.