Skip to content

Commit d43a2c1

Browse files
authored
Add BCR publishing workflow (#275)
Based on https://github.com/bazel-contrib/rules-template
1 parent 84ce696 commit d43a2c1

4 files changed

Lines changed: 122 additions & 3 deletions

File tree

.bcr/config.yml

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

.github/workflows/publish.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish to BCR
2+
on:
3+
# Run the publish workflow after a successful release
4+
# Will be triggered from the release.yaml workflow
5+
workflow_call:
6+
inputs:
7+
tag_name:
8+
required: true
9+
type: string
10+
secrets:
11+
publish_token:
12+
required: true
13+
# In case of problems, let release engineers retry by manually dispatching
14+
# the workflow from the GitHub UI
15+
workflow_dispatch:
16+
inputs:
17+
tag_name:
18+
description: git tag being released
19+
required: true
20+
type: string
21+
jobs:
22+
publish:
23+
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v0.2.2
24+
with:
25+
tag_name: ${{ inputs.tag_name }}
26+
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
27+
registry_fork: bazel-contrib/bazel-central-registry
28+
draft: false
29+
permissions:
30+
attestations: write
31+
contents: write
32+
id-token: write
33+
secrets:
34+
# Necessary to push to the BCR fork, and to open a pull request against a registry
35+
# Inherited from the bazel-contrib org
36+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Automatically perform a release whenever a new "release-like" tag is pushed to the repo.
2+
name: Release
3+
4+
on:
5+
# Can be triggered from the tag.yaml workflow
6+
workflow_call:
7+
inputs:
8+
tag_name:
9+
required: true
10+
type: string
11+
secrets:
12+
publish_token:
13+
required: true
14+
# Or, developers can manually push a tag from their clone
15+
push:
16+
tags:
17+
# Detect tags that look like a release.
18+
- "v*.*.*"
19+
permissions:
20+
id-token: write
21+
attestations: write
22+
contents: write
23+
jobs:
24+
release:
25+
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7.2.2
26+
with:
27+
prerelease: false
28+
release_files: rules_fuzzing-*.tar.gz
29+
tag_name: ${{ inputs.tag_name || github.ref_name }}
30+
publish:
31+
needs: release
32+
uses: ./.github/workflows/publish.yml
33+
with:
34+
tag_name: ${{ inputs.tag_name || github.ref_name }}
35+
secrets:
36+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release_prep.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit -o nounset -o pipefail
4+
5+
# Set by GH actions, see
6+
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
7+
readonly TAG=$1
8+
# The prefix is chosen to match what GitHub generates for source archives.
9+
# This guarantees that users can easily switch from a released artifact to a source archive
10+
# with minimal differences in their code (e.g. strip_prefix remains the same)
11+
readonly PREFIX="rules_fuzzing-${TAG}"
12+
readonly ARCHIVE="${PREFIX}.tar.gz"
13+
14+
# NB: configuration for 'git archive' is in /.gitattributes
15+
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
16+
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
17+
18+
# The stdout of this program will be used as the top of the release notes for this release.
19+
cat << EOF
20+
## Using MODULE.bazel:
21+
22+
\`\`\`starlark
23+
bazel_dep(name = "rules_fuzzing", version = "${VERSION}")
24+
\`\`\`
25+
26+
## Using WORKSPACE:
27+
28+
\`\`\`starlark
29+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
30+
31+
http_archive(
32+
name = "rules_fuzzing",
33+
sha256 = "${SHA}",
34+
strip_prefix = "${PREFIX}",
35+
url = "https://github.com/bazelbuild/rules_fuzzing/releases/download/${TAG}/${ARCHIVE}",
36+
)
37+
38+
load("@rules_fuzzing//fuzzing:repositories.bzl", "rules_fuzzing_dependencies")
39+
40+
rules_fuzzing_dependencies()
41+
42+
load("@rules_fuzzing//fuzzing:init.bzl", "rules_fuzzing_init")
43+
44+
rules_fuzzing_init()
45+
46+
load("@fuzzing_py_deps//:requirements.bzl", "install_deps")
47+
48+
install_deps()
49+
\`\`\`
50+
EOF

0 commit comments

Comments
 (0)