Skip to content

Commit e5e8c59

Browse files
[bazel] Added manual workflow to publish a tag to BCR (#192)
Adds the publish.yaml workflow to manually release a tag to the Bazel Central Registry (BCR). This workflow uses the official reusable publish-to-bcr workflow from the bazel team. BCR template files are added to mirror the existing files in the latest manual bcr release for gz-utils. Also added the compatibility_level field in MODULE.bazel to mirror what is set in BCR for the latest release. Signed-off-by: Shameek Ganguly <[email protected]>
1 parent 5d92b58 commit e5e8c59

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

.bcr/metadata.template.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"homepage": "https://github.com/gazebosim/gz-utils",
3+
"maintainers": [
4+
{
5+
"email": "[email protected]",
6+
"github": "mjcarroll",
7+
"github_user_id": 279701,
8+
"name": "Michael Carroll"
9+
}
10+
],
11+
"repository": [
12+
"github:gazebosim/gz-utils"
13+
],
14+
"versions": [],
15+
"yanked_versions": {}
16+
}

.bcr/presubmit.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
matrix:
2+
platform:
3+
- debian10
4+
- ubuntu2204
5+
- ubuntu2404
6+
- macos
7+
- macos_arm64
8+
bazel:
9+
- 8.x
10+
- 7.x
11+
tasks:
12+
verify_targets:
13+
name: Verify build targets
14+
platform: ${{ platform }}
15+
bazel: ${{ bazel }}
16+
build_flags:
17+
- '--cxxopt=-std=c++17'
18+
- '--host_cxxopt=-std=c++17'
19+
build_targets:
20+
- '@gz-utils//:*'

.bcr/source.template.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrity": "",
3+
"strip_prefix": "{REPO}-{TAG}",
4+
"url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz"
5+
}

.github/workflows/publish.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Publish new releases to Bazel Central Registry.
2+
name: Publish to BCR
3+
on:
4+
# For now, the workflow must be manually triggered.
5+
workflow_dispatch:
6+
inputs:
7+
tag_name:
8+
description: git tag being released
9+
required: true
10+
type: string
11+
jobs:
12+
# The publish-to-bcr reusable workflow expects the version name to be in
13+
# semver-(optional build metadata postfix) format, but the repo tags are in
14+
# branch_semver-postfix format. This job extracts the branch name as a prefix
15+
# to pass to publish-to-bcr.
16+
extract_tag_prefix:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
prefix: ${{ steps.extract.outputs.prefix }}
20+
steps:
21+
- name: Extract the tag prefix from the tag name.
22+
id: extract
23+
run: |
24+
branch=$(echo "${{ inputs.tag_name }}" | cut -d'_' -f1)
25+
prefix="${branch}_"
26+
echo "prefix=${prefix}" | tee -a "$GITHUB_OUTPUT"
27+
28+
publish:
29+
needs: extract_tag_prefix
30+
uses: bazel-contrib/publish-to-bcr/.github/workflows/[email protected]
31+
with:
32+
tag_name: ${{ inputs.tag_name }}
33+
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
34+
registry_fork: gazebo-forks/bazel-central-registry
35+
attest: false
36+
tag_prefix: ${{ needs.extract_tag_prefix.outputs.prefix }}
37+
38+
permissions:
39+
attestations: write
40+
contents: write
41+
id-token: write
42+
secrets:
43+
# Necessary to push to the BCR fork, and to open a pull request against a registry
44+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
module(
44
name = "gz-utils",
5+
compatibility_level = 0,
56
)
67

78
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")

0 commit comments

Comments
 (0)