Skip to content

Commit 9a29da9

Browse files
fix: replace the BCR workflow with the recommended one from bazel-contrib/rules-template
1 parent 81fc9b2 commit 9a29da9

File tree

8 files changed

+157
-79
lines changed

8 files changed

+157
-79
lines changed

.github/workflows/bazel.ci.yml

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

.github/workflows/check.buildifier.yml renamed to .github/workflows/buildifier.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
---
21
name: Buildifier
32

43
# Controls when the action will run.
5-
"on":
4+
on:
65
# Triggers the workflow on push or pull request events but only for the main branch
76
push:
87
branches: [main]
@@ -24,10 +23,6 @@ name: Buildifier
2423

2524
# Allows you to run this workflow manually from the Actions tab
2625
workflow_dispatch:
27-
28-
permissions:
29-
contents: read
30-
3126
jobs:
3227
check:
3328
runs-on: ubuntu-latest

.github/workflows/ci.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the main branch
6+
push:
7+
branches: [main]
8+
pull_request:
9+
branches: [main]
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
concurrency:
14+
# Cancel previous actions from the same PR or branch except 'main' branch.
15+
# See https://docs.github.com/en/actions/using-jobs/using-concurrency and https://docs.github.com/en/actions/learn-github-actions/contexts for more info.
16+
group: concurrency-group::${{ github.workflow }}::${{ github.event.pull_request.number > 0 && format('pr-{0}', github.event.pull_request.number) || github.ref_name }}${{ github.ref_name == 'main' && format('::{0}', github.run_id) || ''}}
17+
cancel-in-progress: ${{ github.ref_name != 'main' }}
18+
19+
jobs:
20+
test:
21+
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@29e53247c6366e30acbedfc767f58f79fc05836c
22+
with:
23+
folders: |
24+
[
25+
".",
26+
]
27+
exclude_windows: true
28+
exclude: |
29+
[
30+
{"bazelversion": "5.4.0", "bzlmodEnabled": true},
31+
{"bazelversion": "5.4.0", "bzlmodEnabled": false},
32+
{"bazelversion": "5.4.0", "os": "macos-latest"},
33+
]

.github/workflows/on.release.yml

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

.github/workflows/publish.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Publish new releases to Bazel Central Registry.
2+
name: Publish to BCR
3+
on:
4+
# Run the publish workflow after a successful release
5+
# Will be triggered from the release.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+
# In case of problems, let release engineers retry by manually dispatching
15+
# the workflow from the GitHub UI
16+
workflow_dispatch:
17+
inputs:
18+
tag_name:
19+
description: git tag being released
20+
required: true
21+
type: string
22+
jobs:
23+
publish:
24+
uses: bazel-contrib/publish-to-bcr/.github/workflows/[email protected]
25+
with:
26+
tag_name: ${{ inputs.tag_name }}
27+
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
28+
registry_fork: sgammon/bazel-central-registry
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+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Cut a release whenever a new tag is pushed to the repo.
2+
name: Release
3+
on:
4+
# Can be triggered from the tag.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+
# Or, developers can manually push a tag from their clone
14+
push:
15+
tags:
16+
- "v*.*.*"
17+
permissions:
18+
id-token: write
19+
attestations: write
20+
contents: write
21+
jobs:
22+
release:
23+
uses: bazel-contrib/.github/.github/workflows/[email protected]
24+
with:
25+
release_files: rules_graalvm-*.tar.gz
26+
prerelease: false
27+
tag_name: ${{ github.ref_name }}
28+
publish:
29+
needs: release
30+
uses: ./.github/workflows/publish.yaml
31+
with:
32+
tag_name: ${{ github.ref_name }}
33+
secrets:
34+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release_prep.sh

100755100644
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
set -o errexit -o nounset -o pipefail
44

5-
# Set by GH actions, see
6-
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
7-
TAG=${GITHUB_REF_NAME}
5+
# Argument provided by reusable workflow caller, see
6+
# https://github.com/bazel-contrib/.github/blob/d197a6427c5435ac22e56e33340dff912bc9334e/.github/workflows/release_ruleset.yaml#L72
7+
TAG=$1
88
# 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)
911
PREFIX="rules_graalvm-${TAG:1}"
10-
ARCHIVE="rules_graalvm-$TAG.tgz"
12+
ARCHIVE="rules_graalvm-$TAG.tar.gz"
13+
14+
# NB: configuration for 'git archive' is in /.gitattributes
1115
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
1216
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
1317

@@ -16,9 +20,9 @@ cat << EOF
1620
1721
See the project repository for documentation.
1822
19-
## Using Bzlmod with Bazel 6+
23+
## Using Bzlmod with Bazel 6 or greater
2024
21-
1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
25+
1. (Bazel 6 only) Enable with \`common --enable_bzlmod\` in \`.bazelrc\`.
2226
2. Add to your \`MODULE.bazel\` file:
2327
2428
\`\`\`starlark
@@ -40,4 +44,4 @@ http_archive(
4044
EOF
4145

4246
awk 'f;/--SNIP--/{f=1}' example/integration_tests/bzlmod/WORKSPACE.bazel
43-
echo "\`\`\`"
47+
echo "\`\`\`"

.github/workflows/tag.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Tag a new release using https://github.com/marketplace/actions/conventional-commits-versioner-action
2+
#
3+
# This is easier than having to run manual `git` operations on a local clone.
4+
# It also runs on a schedule so we don't leave commits unreleased indefinitely
5+
# (avoiding users having to ping "hey could someone cut a release").
6+
7+
name: Tag a Release
8+
on:
9+
# Allow devs to tag manually through the GitHub UI.
10+
# For example after landing a fix that customers are waiting for.
11+
workflow_dispatch:
12+
# Run twice a month, on the 1rst and 15th at 3PM UTC (8AM PST)
13+
# This is a trade-off between making too many releases,
14+
# which overwhelms BCR maintainers and over-notifies users,
15+
# and releasing too infrequently which delays delivery of bugfixes and features.
16+
schedule:
17+
- cron: "0 15 1,15 * *"
18+
jobs:
19+
tag:
20+
permissions:
21+
contents: write # allow create tag
22+
runs-on: ubuntu-latest
23+
outputs:
24+
new-tag: ${{ steps.ccv.outputs.new-tag }}
25+
new-tag-version: ${{steps.ccv.outputs.new-tag-version}}
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
# Need enough history to find the prior release tag
30+
fetch-depth: 0
31+
- name: Bump tag if necessary
32+
id: ccv
33+
uses: smlx/ccv@7318e2f25a52dcd550e75384b84983973251a1f8 # v0.10.0
34+
release:
35+
needs: tag
36+
uses: ./.github/workflows/release.yml
37+
with:
38+
tag_name: ${{ needs.tag.outputs.new-tag-version }}
39+
secrets:
40+
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}
41+
if: needs.tag.outputs.new-tag == 'true' && needs.tag.outputs.new-tag-version-type != 'major'
42+
permissions:
43+
contents: write # allow create release

0 commit comments

Comments
 (0)