Skip to content

Commit caa00cb

Browse files
Use bazel contrib release rules (#319)
Use upstream release rules for bcr usage
1 parent 1ab50b9 commit caa00cb

3 files changed

Lines changed: 68 additions & 28 deletions

File tree

.github/workflows/publish.yaml

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

.github/workflows/release.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Cut a release whenever a new tag is pushed or via workflow_dispatch.
2+
# Uses bazel-contrib release ruleset: build, attest, and publish to GitHub Releases.
3+
name: Release
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
tag_name:
8+
description: Git tag being released
9+
required: true
10+
type: string
11+
push:
12+
tags:
13+
- "v*.*.*"
14+
permissions:
15+
id-token: write
16+
attestations: write
17+
contents: write
18+
jobs:
19+
release:
20+
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7.2.2
21+
with:
22+
release_files: archives/release.tar.gz
23+
prerelease: false
24+
tag_name: ${{ inputs.tag_name || github.ref_name }}
25+
permissions:
26+
id-token: write # Needed to attest provenance
27+
attestations: write # Needed to attest provenance
28+
contents: write # Needed to upload release files
29+
secrets: {}

.github/workflows/release_prep.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit -o nounset -o pipefail
4+
5+
# Argument provided by reusable workflow caller, see
6+
# https://github.com/bazel-contrib/.github/blob/master/.github/workflows/release_ruleset.yaml
7+
TAG=$1
8+
9+
mkdir -p archives
10+
tar --exclude-vcs \
11+
--exclude=bazel-* \
12+
--exclude=.github \
13+
--exclude=archives \
14+
--exclude=cli/src/test \
15+
-zcf "archives/release.tar.gz" .
16+
17+
SHA=$(shasum -a 256 archives/release.tar.gz | awk '{print $1}')
18+
19+
cat << EOF
20+
## Using Bzlmod (MODULE.bazel)
21+
22+
Add to your \`MODULE.bazel\` file:
23+
24+
\`\`\`starlark
25+
bazel_dep(name = "bazel-diff", version = "${TAG#v}")
26+
\`\`\`
27+
28+
## Using WORKSPACE
29+
30+
\`\`\`starlark
31+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
32+
http_archive(
33+
name = "bazel-diff",
34+
sha256 = "${SHA}",
35+
strip_prefix = "",
36+
url = "https://github.com/Tinder/bazel-diff/releases/download/${TAG}/release.tar.gz",
37+
)
38+
\`\`\`
39+
EOF

0 commit comments

Comments
 (0)