Skip to content

Commit 5e35cf3

Browse files
committed
begin bcr publish pipeline
1 parent 66f16c1 commit 5e35cf3

8 files changed

Lines changed: 130 additions & 165 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
# Allows you to run this workflow manually from the Actions tab
1212
workflow_dispatch:
1313

14+
concurrency:
15+
# Cancel previous actions from the same PR: https://stackoverflow.com/a/72408109
16+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
17+
cancel-in-progress: true
18+
1419
jobs:
1520
test:
1621
# The type of runner that the job will run on

.github/workflows/format.yaml

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://github.com/bazel-contrib/publish-to-bcr
2+
name: Publish to BCR
3+
4+
on:
5+
# Run the publish workflow after a successful release
6+
# Can be triggered from the release.yaml workflow
7+
workflow_call:
8+
inputs:
9+
tag_name:
10+
required: true
11+
type: string
12+
secrets:
13+
BCR_PUBLISH_TOKEN:
14+
required: true
15+
# In case of problems, let release engineers retry by manually dispatching
16+
# the workflow from the GitHub UI
17+
workflow_dispatch:
18+
inputs:
19+
tag_name:
20+
description: 'Publish to BCR'
21+
required: true
22+
type: string
23+
24+
jobs:
25+
publish:
26+
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v0.1.0
27+
with:
28+
draft: false
29+
tag_name: ${{ inputs.tag_name }}
30+
permissions:
31+
attestations: write
32+
contents: write
33+
id-token: write
34+
secrets:
35+
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release.yaml

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
# Cut a release whenever a new tag is pushed to the repo.
1+
# Based on https://github.com/bazel-contrib/rules-template/blob/main/.github/workflows/release.yaml.
22
name: Release
3-
43
on:
54
push:
65
tags:
7-
- "v*.*.*"
8-
9-
# Allows owner to run this workflow manually from the Actions tab
6+
- "*.*.*"
107
workflow_dispatch:
11-
8+
inputs:
9+
tag_name:
10+
description: git tag to release. The tag must exist.
11+
required: true
12+
type: string
1213
jobs:
13-
test:
14-
# The type of runner that the job will run on
15-
runs-on: ubuntu-latest
16-
17-
# Steps represent a sequence of tasks that will be executed as part of the job
18-
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v4
21-
22-
- name: Prepare workspace snippet
23-
run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
24-
25-
- name: Release
26-
uses: softprops/action-gh-release@v1
27-
with:
28-
prerelease: false
29-
# Use GH feature to populate the changelog automatically
30-
generate_release_notes: true
31-
body_path: release_notes.txt
14+
release:
15+
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7.2.2
16+
with:
17+
release_files: rules_proto-*.tar.gz
18+
prerelease: true
19+
tag_name: ${{ inputs.tag_name || github.ref_name }}
20+
permissions:
21+
attestations: write
22+
contents: write
23+
id-token: write
24+
publish:
25+
needs: release
26+
uses: ./.github/workflows/publish-to-bcr.yaml
27+
with:
28+
tag_name: ${{ inputs.tag_name || github.ref_name }}
29+
secrets:
30+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/workspace_snippet.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

example/golden/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ gazelle_testdata_example(
308308
bazel_dep(name = "protobuf", version = "32.0", repo_name = "com_google_protobuf")
309309
""",
310310
strip_prefix = "example/golden/testdata/starlark_java",
311+
tags = ["manual"], # TODO(pcj): figure out why this one is timing out in CI (gh actions)
311312
)
312313

313314
gazelle_testdata_example(

rules/go/README.md

Lines changed: 65 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -138,85 +138,80 @@ bazel_dep(name = "build_stack_rules_proto", version = "0.0.0")
138138
# -------------------------------------------------------------------
139139

140140
proto_repository = use_extension("@build_stack_rules_proto//extensions:proto_repository.bzl", "proto_repository", dev_dependency = True)
141+
proto_repository.archive(
142+
name = "protobufapis",
143+
build_directives = [
144+
"gazelle:exclude testdata",
145+
"gazelle:exclude google/protobuf/compiler/ruby",
146+
"gazelle:exclude google/protobuf/bridge",
147+
"gazelle:exclude google/protobuf/util/internal/testdata",
148+
"gazelle:proto_language go enable true",
149+
],
150+
build_file_proto_mode = "file",
151+
build_file_generation = "clean",
152+
cfgs = ["@//:rules_proto_config.yaml"],
153+
deleted_files = [
154+
"google/protobuf/*test*.proto",
155+
"google/protobuf/*unittest*.proto",
156+
"google/protobuf/late*.proto",
157+
"google/protobuf/sample*.proto",
158+
"google/protobuf/cpp_features.proto",
159+
"google/protobuf/internal_options.proto",
160+
"google/protobuf/compiler/cpp/*test*.proto",
161+
"google/protobuf/util/*test*.proto",
162+
"google/protobuf/util/*unittest*.proto",
163+
"google/protobuf/util/json_format*.proto",
164+
],
165+
sha256 = "bb1fd58473c47c747a3f00fc45ced1d562bba4bf645db07cc889fe86dee279ca",
166+
strip_prefix = "protobuf-4fbd1111a292d04746c732573025e3251de0bb9c/src",
167+
urls = ["https://github.com/protocolbuffers/protobuf/archive/4fbd1111a292d04746c732573025e3251de0bb9c.tar.gz"],
168+
)
141169
proto_repository.archive(
142170
name = "googleapis",
171+
build_file_generation = "clean",
143172
build_directives = [
144-
"gazelle:proto_go_modules_target_dir ROOT",
145-
"gazelle:exclude google/example",
173+
"gazelle:exclude google/ads/googleads/v19/services",
174+
"gazelle:exclude google/ads/googleads/v20/services",
175+
"gazelle:exclude google/ads/googleads/v21/services",
146176
"gazelle:exclude google/ads/googleads/v7/services",
147177
"gazelle:exclude google/ads/googleads/v8/services",
148-
"gazelle:proto_language go enabled true",
178+
"gazelle:exclude google/cloud/recommendationengine/v1beta1",
179+
"gazelle:exclude google/devtools/containeranalysis/v1beta1",
180+
"gazelle:exclude google/example",
181+
"gazelle:exclude google/maps/weather/v1",
182+
"gazelle:proto_go_modules_enabled true",
183+
"gazelle:proto_language go enable true",
149184
],
150-
build_file_generation = "clean",
151185
build_file_proto_mode = "file",
152186
cfgs = ["//:rules_proto_config.yaml"],
153-
imports = ["@protoapis//:imports.csv"],
187+
imports = ["@protobufapis//:imports.csv"],
154188
reresolve_known_proto_imports = True,
155-
sha256 = "95da12951c7d570980d5152f6cca9e1cb795ddc6b6dd7e9423bdffde28290f7a",
156-
strip_prefix = "googleapis-02710fa0ea5312d79d7fb986c9c9823fb41049a9",
157-
type = "zip",
158-
urls = [
159-
"https://codeload.github.com/googleapis/googleapis/zip/02710fa0ea5312d79d7fb986c9c9823fb41049a9",
160-
],
189+
sha256 = "b1f729e116312e1bed9a6c0b812e8d6071755dcf93ff4f665c07bbf517dd61a6",
190+
strip_prefix = "googleapis-60e1300d4a0b60b85b3df167ddc4062ac7cc4f44",
191+
urls = ["https://github.com/googleapis/googleapis/archive/60e1300d4a0b60b85b3df167ddc4062ac7cc4f44.tar.gz"],
161192
)
162193
proto_repository.archive(
163194
name = "remoteapis",
164195
build_directives = [
165-
"gazelle:proto_go_modules_target_dir ROOT",
166196
"gazelle:exclude third_party",
167-
"gazelle:exclude build/bazel/remote/asset/v1",
168-
"gazelle:exclude build/bazel/remote/logstream/v1",
197+
"gazelle:proto_go_modules_enabled true",
169198
"gazelle:proto_language go enable true",
170-
"gazelle:proto_plugin protoc-gen-go option Mbuild/bazel/remote/execution/v2/remote_execution.proto=github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2",
171-
"gazelle:proto_plugin protoc-gen-go option Mbuild/bazel/semver/semver.proto=github.com/bazelbuild/remote-apis/build/bazel/semver",
172-
"gazelle:proto_plugin protoc-gen-go-grpc option Mbuild/bazel/remote/execution/v2/remote_execution.proto=github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2",
173-
"gazelle:proto_plugin protoc-gen-go-grpc option Mbuild/bazel/semver/semver.proto=github.com/bazelbuild/remote-apis/build/bazel/semver",
174199
],
175200
build_file_generation = "clean",
176201
build_file_proto_mode = "file",
177202
cfgs = ["//:rules_proto_config.yaml"],
178203
imports = [
179204
"@googleapis//:imports.csv",
180-
"@protoapis//:imports.csv",
181-
],
182-
sha256 = "743d2d5b5504029f3f825beb869ce0ec2330b647b3ee465a4f39ca82df83f8bf",
183-
strip_prefix = "remote-apis-636121a32fa7b9114311374e4786597d8e7a69f3",
184-
type = "zip",
185-
urls = [
186-
"https://codeload.github.com/bazelbuild/remote-apis/zip/636121a32fa7b9114311374e4786597d8e7a69f3",
187-
],
188-
)
189-
proto_repository.archive(
190-
name = "protoapis",
191-
build_directives = [
192-
"gazelle:proto_go_modules_target_dir ROOT",
193-
"gazelle:exclude testdata",
194-
"gazelle:exclude google/protobuf/compiler/ruby",
195-
"gazelle:exclude google/protobuf/util/internal/testdata",
196-
"gazelle:proto_language go enable true",
197-
],
198-
build_file_generation = "clean",
199-
build_file_proto_mode = "file",
200-
cfgs = ["//:rules_proto_config.yaml"],
201-
deleted_files = [
202-
"google/protobuf/*test*.proto",
203-
"google/protobuf/*unittest*.proto",
204-
"google/protobuf/compiler/cpp/*test*.proto",
205-
"google/protobuf/util/*test*.proto",
206-
"google/protobuf/util/*unittest*.proto",
207-
"google/protobuf/util/json_format*.proto",
208-
],
209-
sha256 = "4514213c25a5b87e1948aeeb4c40effc55d11d60871ca5b903a2779005fc48ce",
210-
strip_prefix = "protobuf-9650e9fe8f737efcad485c2a8e6e696186ae3862/src",
211-
type = "zip",
212-
urls = [
213-
"https://codeload.github.com/protocolbuffers/protobuf/zip/9650e9fe8f737efcad485c2a8e6e696186ae3862",
205+
"@protobufapis//:imports.csv",
214206
],
207+
sha256 = "7b6847779f18fe0a586c8629b9347cf5e54edb0c9fb7cd7b56c489c0209409c2",
208+
strip_prefix = "remote-apis-6777112ef7defa6705b1ebd2831d6c7efeb12ba2",
209+
urls = ["https://github.com/bazelbuild/remote-apis/archive/6777112ef7defa6705b1ebd2831d6c7efeb12ba2.tar.gz"],
215210
)
216211
use_repo(
217212
proto_repository,
218213
"googleapis",
219-
"protoapis",
214+
"protobufapis",
220215
"remoteapis",
221216
)
222217
```
@@ -227,10 +222,9 @@ few extra gazelle directives that are injected into the generated root
227222

228223
1. turns on go protobuf rule generation for `go` (`gazelle:proto_language go
229224
enable true`)
230-
2. turns on the gazelle lang `proto_go_modules` by setting the target package to
231-
the special token `ROOT` (`gazelle:proto_go_modules_target_dir ROOT`).
225+
2. turns on the gazelle lang `proto_go_modules` (`gazelle:proto_go_modules_enabled true`).
232226

233-
When the requested (e.g. `bazel query @protoapis//...`), bazel will:
227+
When the requested (e.g. `bazel query @protobufapis//...`), bazel will:
234228

235229
1. download and extract the zip file
236230
2. remove all existing `BUILD.bazel` files in the workspace
@@ -247,26 +241,26 @@ rule include all the generated `proto_go_library` rules in the repo (`GoArchive`
247241
providers):
248242

249243
```sh
250-
bazel query @protoapis//:proto_go_modules --output build
244+
bazel query @protobufapis//:proto_go_modules --output build
251245
```
252246

253247
```py
254248
proto_go_modules(
255249
name = "proto_go_modules",
256250
visibility = ["//visibility:public"],
257251
deps = [
258-
"@protoapis//google/protobuf:any_go_proto",
259-
"@protoapis//google/protobuf:api_go_proto",
260-
"@protoapis//google/protobuf:descriptor_go_proto",
261-
"@protoapis//google/protobuf:duration_go_proto",
262-
"@protoapis//google/protobuf:empty_go_proto",
263-
"@protoapis//google/protobuf:field_mask_go_proto",
264-
"@protoapis//google/protobuf:source_context_go_proto",
265-
"@protoapis//google/protobuf:struct_go_proto",
266-
"@protoapis//google/protobuf:timestamp_go_proto",
267-
"@protoapis//google/protobuf:type_go_proto",
268-
"@protoapis//google/protobuf:wrappers_go_proto",
269-
"@protoapis//google/protobuf/compiler:plugin_go_proto",
252+
"@protobufapis//google/protobuf:any_go_proto",
253+
"@protobufapis//google/protobuf:api_go_proto",
254+
"@protobufapis//google/protobuf:descriptor_go_proto",
255+
"@protobufapis//google/protobuf:duration_go_proto",
256+
"@protobufapis//google/protobuf:empty_go_proto",
257+
"@protobufapis//google/protobuf:field_mask_go_proto",
258+
"@protobufapis//google/protobuf:source_context_go_proto",
259+
"@protobufapis//google/protobuf:struct_go_proto",
260+
"@protobufapis//google/protobuf:timestamp_go_proto",
261+
"@protobufapis//google/protobuf:type_go_proto",
262+
"@protobufapis//google/protobuf:wrappers_go_proto",
263+
"@protobufapis//google/protobuf/compiler:plugin_go_proto",
270264
],
271265
)
272266
```
@@ -284,7 +278,7 @@ proto_go_modules(
284278
],
285279
modules = [
286280
"@googleapis//:proto_go_modules",
287-
"@protoapis//:proto_go_modules",
281+
"@protobufapis//:proto_go_modules",
288282
"@remoteapis//:proto_go_modules",
289283
],
290284
)
@@ -339,4 +333,4 @@ go mod edit -replace github.com/bazelbuild/remoteapis/build/bazel/semver/semver=
339333

340334
> NOTE: the script does not remove old entries, so you may need to `rm -rf
341335
> ./local` and manually tweak the `go.mod` file in the case of removing
342-
> `imports` from the `proto_go_modules` rule.
336+
> `imports` from the `proto_go_modules` rule.

rules/go/proto_go_modules.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ def _proto_go_modules_impl(ctx):
3232
for go_archive in direct.values()
3333
if _is_proto_dep(go_archive.data)
3434
]
35-
# for go_archive in direct.values():
36-
# if _is_proto_dep(go_archive.data):
37-
# available_imports.appgo_archive.data.importpath] = go_archive.data
3835

3936
# collect the final list of deps we want to vendor sources for
4037
want = {}

0 commit comments

Comments
 (0)