Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"homepage": "https://github.com/bmw-software-engineering/trlc",
"maintainers": [
{
"email": "Ambuj.Singh@bti.bmwgroup.com",
"github": "AAmbuj",
"name": "Ambuj Singh Kushwaha",
"github_user_id": 73685939
},
{
"email": "Rahul.Sutariya@bti.bmwgroup.com",
"github": "Rahul-Sutariya",
"name": "RAHUL SUTARIYA",
"github_user_id": 113970414
}
],
"repository": [
"github:bmw-software-engineering/trlc"
],
"versions": [],
"yanked_versions": {}
}

26 changes: 26 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
incompatible_flags:
"--incompatible_config_setting_private_default_visibility":
- 8.x
"--incompatible_disable_starlark_host_transitions":
- 8.x
"--incompatible_disable_native_repo_rules":
- 8.x
"--incompatible_strict_action_env":
- 8.x
matrix:
platform:
- ubuntu2204
- windows
bazel:
- 8.x
tasks:
verify_api_examples:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Verify API Examples (presubmit.yml L18-27)
    Question: What is happening here?

Answer: This is the BCR's standard "anonymous module test". It verifies that when a downstream user depends on TRLC as an external Bazel module, the api-examples/ directory builds and passes tests correctly.

The BCR CI creates a simple anonymous module with:

bazel_dep(name = "trlc", version = "X.Y.Z")
Then it builds/tests @trlc//api-examples/... to confirm the published module works for consumers. The test_flags line pins Python 3.12 via the rules_python config setting.

Action: No change needed — working as intended.

name: "Verify api-examples"
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- "@trlc//api-examples/..."
test_flags:
- "--@@rules_python+//python/config_settings:python_version=3.12"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we expose python 3.9-3.12 should have also tests for it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do this changes but its doesn't make sense to do because its only run to the BCR CI so just we have to pass at any version that it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you still want i can update this way:
python_version:

  • "3.9"
  • "3.10"
  • "3.11"
  • "3.12"
    bazel:
  • 8.x
    tasks:
    verify_api_examples:
    name: "Verify api-examples (Python {python_version})"
    platform: ${{ platform }}
    bazel: ${{ bazel }}
    build_targets:
    • "@trlc//api-examples/..."
      test_flags:
    • "--@@rules_python+//python/config_settings:python_version=${{ python_version }}"
      test_targets:
    • "@trlc//api-examples/..."

test_targets:
- "@trlc//api-examples/..."
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "**leave this alone**",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. "Leave this alone" (source.template.json L2)
    Question: What shall be left alone?

Answer: The literal text leave this alone is a placeholder from the publish-to-bcr tooling. When the automation runs, it automatically computes the SHA-256 integrity hash of the source archive and replaces this field. The text instructs maintainers: "don't manually fill in a value here — the tooling handles it."

This is the standard template pattern used by all projects using publish-to-bcr.

Action: No change needed — this is intentional.

"strip_prefix": "{REPO}-{VERSION}",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{TAG}.tar.gz"
}
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish to BCR

on:
workflow_call:
inputs:
tag_name:
required: true
type: string
registry_fork:
required: false
type: string
default: bmw-software-engineering/bazel-central-registry
secrets:
BCR_PUBLISH_TOKEN:
required: true
workflow_dispatch:
inputs:
tag_name:
description: Git tag being released
required: true
type: string
registry_fork:
description: GitHub fork used to open the BCR PR (owner/repo)
required: false
type: string
default: bmw-software-engineering/bazel-central-registry

jobs:
publish:
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.2.0
with:
tag_name: ${{ inputs.tag_name }}
registry_fork: ${{ inputs.registry_fork }}
draft: false
attest: true
tag_prefix: "trlc-"
permissions:
contents: write
id-token: write
attestations: write
secrets:
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release

on:
workflow_dispatch:
inputs:
tag_name:
description: Git tag being released
required: true
type: string
registry_fork:
description: GitHub fork used to open the BCR PR (owner/repo)
required: false
type: string
default: bmw-software-engineering/bazel-central-registry
push:
tags:
- "trlc-*"

permissions:
id-token: write
attestations: write
contents: write

jobs:
release:
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7.4.0
with:
release_files: archives/*.*
prerelease: false
draft: true
tag_name: ${{ inputs.tag_name || github.ref_name }}
bazel_test_command: "echo 'Tests skipped during release (run in CI workflow)'"
mount_bazel_caches: false
permissions:
id-token: write
attestations: write
contents: write
secrets: {}

publish:
needs: release
uses: ./.github/workflows/publish.yml
with:
tag_name: ${{ inputs.tag_name || github.ref_name }}
registry_fork: ${{ inputs.registry_fork || 'bmw-software-engineering/bazel-central-registry' }}
secrets:
BCR_PUBLISH_TOKEN: ${{ secrets.BCR_PUBLISH_TOKEN }}

finalize:
needs: publish
runs-on: ubuntu-24.04

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Platforms (presubmit.yml L12-14, release.yml L51)
    Question: Why did you pick these platforms, and only these?

Answer: The platforms ubuntu2004, ubuntu2204, and windows are selected from the fixed set available in the BCR presubmit CI infrastructure (Bazel CI on BuildKite). The full list of supported platform labels is defined in the PLATFORMS variable in bazelci.py. Available options include rockylinux8, debian10, ubuntu2004, ubuntu2204, macos, macos_arm64, windows, among others (see BCR docs – Anonymous module test).

Since TRLC is a pure Python module with no native/compiled components, the two most common Linux environments plus Windows (for path-handling differences) provide sufficient coverage. macos can be added if desired.

The ubuntu-24.04 in release.yml L51 is a GitHub Actions runner (not a BCR platform) — it only runs gh release edit to publish a draft release, so any Linux runner suffices.

Action: No change needed unless macOS coverage is desired.

permissions:
contents: write
steps:
- name: Publish draft release
run: gh release edit "$TAG" --draft=false --repo "$GITHUB_REPOSITORY"
env:
TAG: ${{ inputs.tag_name || github.ref_name }}
GH_TOKEN: ${{ github.token }}
44 changes: 44 additions & 0 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Release Preparations (release_prep.sh)
    Question: What is the purpose of this file?

Answer: This script:

Validates the tag format (must match trlc-X.Y.Z)
Creates a reproducible source archive using git archive
Computes the SHA-256 checksum
Prints Markdown snippets (Bzlmod + WORKSPACE installation instructions) for GitHub Release notes
It generates release artifacts and user-facing documentation.

Action: No change needed.


set -o errexit -o nounset -o pipefail

TAG="$1"
# Tags use the format "trlc-X.Y.Z"; strip the prefix to get the bare version
# matching the tag_prefix configured in publish.yml
if [[ "$TAG" == trlc-* ]]; then
VERSION="${TAG#trlc-}"
else
echo "ERROR: tag '${TAG}' does not match expected format 'trlc-X.Y.Z'" >&2
exit 1
fi

mkdir -p archives

PREFIX="trlc-${VERSION}"
ARCHIVE="archives/${TAG}.tar.gz"

git archive --format=tar --prefix="${PREFIX}/" "$TAG" | gzip > "$ARCHIVE"

SHA=$(sha256sum "$ARCHIVE" | awk '{print $1}')

cat << EOF
## Bzlmod

Add this to your MODULE.bazel:

\`\`\`starlark
bazel_dep(name = "trlc", version = "${VERSION}")
\`\`\`

## WORKSPACE

\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "trlc",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/bmw-software-engineering/trlc/releases/download/${TAG}/${TAG}.tar.gz",
)
\`\`\`
EOF
72 changes: 72 additions & 0 deletions documentation/TUTORIAL-BCR-RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Automated TRLC to BCR Release

This document describes the automated release flow that publishes TRLC
to the [Bazel Central Registry](https://github.com/bazelbuild/bazel-central-registry)
(BCR).

## How It Works

Releases are automated through GitHub Actions:

1. Push a release tag using the format `trlc-X.Y.Z`.
2. Workflow [`release.yml`](../.github/workflows/release.yml) creates a draft GitHub
release and uploads `trlc-{TAG}.tar.gz`.
3. Workflow [`publish.yml`](../.github/workflows/publish.yml) opens a Bazel Central
Registry PR through
[publish-to-bcr](https://github.com/bazel-contrib/publish-to-bcr).
4. After BCR publish succeeds, the release is finalized (published),
which triggers [`package.yml`](../.github/workflows/package.yml) to publish wheels to
PyPI.

## Required Repository Secret

* `BCR_PUBLISH_TOKEN`: Classic PAT with `workflow` and `repo` scopes,
with access to your BCR fork (default fork:
`bmw-software-engineering/bazel-central-registry`).

## BCR Template Files

The [`.bcr/`](../.bcr/) directory contains template files used by the
`publish-to-bcr` action:

| File | Purpose |
|------|---------|
| [`presubmit.yml`](../.bcr/presubmit.yml) | Defines BCR presubmit CI: platforms, build/test targets |
| [`source.template.json`](../.bcr/source.template.json) | Template for the source archive URL and integrity hash |
| [`metadata.template.json`](../.bcr/metadata.template.json) | Module metadata (maintainers, homepage) |

## Presubmit Platforms

The BCR CI runs on platforms from the
[Bazel CI infrastructure](https://github.com/bazelbuild/continuous-integration/blob/master/buildkite/bazelci.py).
Currently configured: `ubuntu2204`, `windows`.

## Release Preparation Script

[`release_prep.sh`](../.github/workflows/release_prep.sh) is a helper that:

1. Validates the tag format (`trlc-X.Y.Z`)
2. Creates a reproducible source archive via `git archive`
3. Computes the SHA-256 checksum
4. Prints Markdown install snippets (Bzlmod and WORKSPACE) for release
notes

## Triggering a Release

```bash
# Tag and push
git tag trlc-1.2.3
git push origin trlc-1.2.3
```

The `push: tags: ["trlc-*"]` trigger in [`release.yml`](../.github/workflows/release.yml) starts the
pipeline automatically.

## Manual Dispatch

Both [`release.yml`](../.github/workflows/release.yml) and [`publish.yml`](../.github/workflows/publish.yml) support `workflow_dispatch` for
manual re-runs from the GitHub Actions UI. You must provide:

* `tag_name`: the git tag (e.g. `trlc-1.2.3`)
* `registry_fork`: the BCR fork to push to (e.g.
`bmw-software-engineering/bazel-central-registry`)
2 changes: 2 additions & 0 deletions documentation/TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@
* [Advaned tips & tricks](TUTORIAL-ADVANCED-TYPES.md): some more
advanced tips and tricks for large organisations
* [Python API](TUTORIAL-API.md): writing a custom check with the API
* [Bazel Integration](TUTORIAL-BAZEL.md): using TRLC with Bazel
* [BCR Release](TUTORIAL-BCR-RELEASE.md): automated publishing to the Bazel Central Registry
* [CI Integration](TUTORIAL-CI.md): tips on how to integrate in your CI
Loading