-
Notifications
You must be signed in to change notification settings - Fork 24
Added automated TRLC to BCR release pipeline #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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": {} | ||
| } | ||
|
|
| 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: | ||
| name: "Verify api-examples" | ||
| platform: ${{ platform }} | ||
| bazel: ${{ bazel }} | ||
| build_targets: | ||
| - "@trlc//api-examples/..." | ||
| test_flags: | ||
| - "--@@rules_python+//python/config_settings:python_version=3.12" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you still want i can update this way:
|
||
| test_targets: | ||
| - "@trlc//api-examples/..." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "integrity": "**leave this alone**", | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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" | ||
| } | ||
| 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 }} |
| 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 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/usr/bin/env bash | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Answer: This script: Validates the tag format (must match trlc-X.Y.Z) 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 | ||
| 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`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.