Skip to content

Commit 08cd7df

Browse files
committed
fix: clarify sync step
1 parent 62b52ab commit 08cd7df

File tree

3 files changed

+100
-67
lines changed

3 files changed

+100
-67
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Enrich Release Notes
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
format:
13+
name: Format published release
14+
runs-on: ubuntu-latest
15+
if: ${{ github.event.release.draft == false }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
ref: ${{ github.event.release.tag_name }}
21+
22+
- name: Update release body with install instructions
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
REPOSITORY: ${{ github.repository }}
26+
TAG_NAME: ${{ github.event.release.tag_name }}
27+
RAW_VERSION: ${{ github.event.release.tag_name }}
28+
RELEASE_BODY: ${{ github.event.release.body }}
29+
run: |
30+
set -euo pipefail
31+
32+
version="${RAW_VERSION#v}"
33+
tar_url="https://github.com/${REPOSITORY}/archive/refs/tags/${TAG_NAME}.tar.gz"
34+
tmp_archive="$(mktemp)"
35+
curl -sSL "${tar_url}" -o "${tmp_archive}"
36+
sha256="$(shasum -a 256 "${tmp_archive}" | cut -d ' ' -f1)"
37+
rm "${tmp_archive}"
38+
export SHA256="${sha256}"
39+
40+
python - <<'PY' > release-body.md
41+
import os, textwrap
42+
43+
repo = os.environ["REPOSITORY"]
44+
tag = os.environ["TAG_NAME"]
45+
version = os.environ["RAW_VERSION"].lstrip("v")
46+
tar_url = f"https://github.com/{repo}/archive/refs/tags/{tag}.tar.gz"
47+
sha256 = os.environ["SHA256"]
48+
existing = os.environ.get("RELEASE_BODY", "").strip()
49+
50+
body = textwrap.dedent(f"""\
51+
## Install with Bzlmod
52+
53+
Add to your `MODULE.bazel`:
54+
55+
```starlark
56+
bazel_dep(name = "rules_sbom", version = "{version}")
57+
58+
load("@rules_sbom//sbom:setup.bzl", "rules_sbom_setup")
59+
syft_repo = use_repo_rule("@rules_sbom//sbom:repositories.bzl", "syft_repository")
60+
rules_sbom_setup(syft_repo)
61+
```
62+
63+
## Install with a WORKSPACE
64+
65+
Download and pin the release archive:
66+
67+
- URL: `{tar_url}`
68+
- SHA256: `{sha256}`
69+
70+
Then in your `WORKSPACE` file:
71+
72+
```starlark
73+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
74+
75+
http_archive(
76+
name = "rules_sbom",
77+
urls = ["{tar_url}"],
78+
strip_prefix = "rules_sbom-{version}",
79+
sha256 = "{sha256}",
80+
)
81+
82+
load("@rules_sbom//sbom:repositories.bzl", "syft_repository")
83+
load("@rules_sbom//sbom:setup.bzl", "rules_sbom_setup")
84+
85+
rules_sbom_setup(syft_repository)
86+
```
87+
88+
See [docs/overview.md](https://github.com/{repo}/blob/{tag}/docs/overview.md) for advanced configuration options.
89+
90+
---
91+
92+
{existing}
93+
""")
94+
95+
print(body)
96+
PY
97+
98+
gh release edit "${TAG_NAME}" --notes-file release-body.md

.github/workflows/release.yml

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ jobs:
1515
name: Create Release Pull Request
1616
runs-on: ubuntu-latest
1717
steps:
18-
- id: release
19-
uses: googleapis/release-please-action@v4
18+
- uses: googleapis/release-please-action@v4
2019
with:
2120
pull-request-header: |
2221
## Release Preview
@@ -26,67 +25,3 @@ jobs:
2625
---
2726
2827
Once merged, Release Please will tag `v${version}` and publish the GitHub release automatically.
29-
- name: Enrich release notes with install instructions
30-
if: steps.release.outputs.release_created == 'true'
31-
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-
TAG_NAME: ${{ steps.release.outputs.tag_name }}
34-
VERSION: ${{ steps.release.outputs.version }}
35-
REPOSITORY: ${{ github.repository }}
36-
run: |
37-
set -euo pipefail
38-
39-
TAR_URL="https://github.com/${REPOSITORY}/archive/refs/tags/${TAG_NAME}.tar.gz"
40-
TMP_ARCHIVE="$(mktemp)"
41-
curl -sSL "${TAR_URL}" -o "${TMP_ARCHIVE}"
42-
SHA256="$(shasum -a 256 "${TMP_ARCHIVE}" | cut -d ' ' -f1)"
43-
rm "${TMP_ARCHIVE}"
44-
45-
EXISTING_BODY="$(gh release view "${TAG_NAME}" --json body --jq '.body')"
46-
47-
cat > release-body.md <<EOF
48-
## Install with Bzlmod
49-
50-
Add to your \`MODULE.bazel\`:
51-
52-
\`\`\`starlark
53-
bazel_dep(name = "rules_sbom", version = "${VERSION}")
54-
55-
load("@rules_sbom//sbom:setup.bzl", "rules_sbom_setup")
56-
syft_repo = use_repo_rule("@rules_sbom//sbom:repositories.bzl", "syft_repository")
57-
rules_sbom_setup(syft_repo)
58-
\`\`\`
59-
60-
## Install with a WORKSPACE
61-
62-
Download and pin the release archive:
63-
64-
- URL: \`${TAR_URL}\`
65-
- SHA256: \`${SHA256}\`
66-
67-
Then in your \`WORKSPACE\` file:
68-
69-
\`\`\`starlark
70-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
71-
72-
http_archive(
73-
name = "rules_sbom",
74-
urls = ["${TAR_URL}"],
75-
strip_prefix = "rules_sbom-${VERSION}",
76-
sha256 = "${SHA256}",
77-
)
78-
79-
load("@rules_sbom//sbom:repositories.bzl", "syft_repository")
80-
load("@rules_sbom//sbom:setup.bzl", "rules_sbom_setup")
81-
82-
rules_sbom_setup(syft_repository)
83-
\`\`\`
84-
85-
See [docs/overview.md](https://github.com/${REPOSITORY}/blob/${TAG_NAME}/docs/overview.md) for advanced configuration options.
86-
87-
---
88-
89-
${EXISTING_BODY}
90-
EOF
91-
92-
gh release edit "${TAG_NAME}" --notes-file release-body.md

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ Once changes land on `main`, the GitHub action opens a release PR. Merging that
5151

5252
If you need to double-check a release manually, re-run the `Release Please` workflow from the Actions tab; it will only open a new PR when there are user-facing commits since the last tag.
5353

54-
Use `bazel sync` after upgrading to ensure the Syft toolchain archives download for your host platform.
54+
Use `bazel sync` after upgrading to ensure the Syft toolchain archives download for your host platform; this refreshes the Syft binaries for the host OS/architecture.

0 commit comments

Comments
 (0)