Skip to content

Commit 66f1d47

Browse files
committed
Merge branch 'main' into release/1.7
2 parents ebc6640 + 6f80d34 commit 66f1d47

File tree

34 files changed

+137
-45
lines changed

34 files changed

+137
-45
lines changed

.bazelci/presubmit.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -329,41 +329,41 @@ tasks:
329329
<<: *minimum_supported_version
330330
<<: *reusable_build_test_all
331331
<<: *coverage_targets_example_bzlmod_build_file_generation
332-
name: "examples/bzlmod_build_file_generation: Ubuntu, minimum Bazel"
333-
working_directory: examples/bzlmod_build_file_generation
332+
name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu, minimum Bazel"
333+
working_directory: gazelle/examples/bzlmod_build_file_generation
334334
platform: ubuntu2204
335335
bazel: 7.x
336336
integration_test_bzlmod_generation_build_files_ubuntu:
337337
<<: *reusable_build_test_all
338338
<<: *coverage_targets_example_bzlmod_build_file_generation
339-
name: "examples/bzlmod_build_file_generation: Ubuntu"
340-
working_directory: examples/bzlmod_build_file_generation
339+
name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu"
340+
working_directory: gazelle/examples/bzlmod_build_file_generation
341341
platform: ubuntu2204
342342
integration_test_bzlmod_generation_build_files_ubuntu_run:
343343
<<: *reusable_build_test_all
344-
name: "examples/bzlmod_build_file_generation: Ubuntu, Gazelle and pip"
345-
working_directory: examples/bzlmod_build_file_generation
344+
name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu, Gazelle and pip"
345+
working_directory: gazelle/examples/bzlmod_build_file_generation
346346
platform: ubuntu2204
347347
shell_commands:
348348
- "bazel run //:gazelle_python_manifest.update"
349349
- "bazel run //:gazelle -- update"
350350
integration_test_bzlmod_build_file_generation_debian:
351351
<<: *reusable_build_test_all
352352
<<: *coverage_targets_example_bzlmod_build_file_generation
353-
name: "examples/bzlmod_build_file_generation: Debian"
354-
working_directory: examples/bzlmod_build_file_generation
353+
name: "gazelle/examples/bzlmod_build_file_generation: Debian"
354+
working_directory: gazelle/examples/bzlmod_build_file_generation
355355
platform: debian11
356356
integration_test_bzlmod_build_file_generation_macos:
357357
<<: *reusable_build_test_all
358358
<<: *coverage_targets_example_bzlmod_build_file_generation
359-
name: "examples/bzlmod_build_file_generation: MacOS"
360-
working_directory: examples/bzlmod_build_file_generation
359+
name: "gazelle/examples/bzlmod_build_file_generation: MacOS"
360+
working_directory: gazelle/examples/bzlmod_build_file_generation
361361
platform: macos
362362
integration_test_bzlmod_build_file_generation_windows:
363363
<<: *reusable_build_test_all
364364
# coverage is not supported on Windows
365-
name: "examples/bzlmod_build_file_generation: Windows"
366-
working_directory: examples/bzlmod_build_file_generation
365+
name: "gazelle/examples/bzlmod_build_file_generation: Windows"
366+
working_directory: gazelle/examples/bzlmod_build_file_generation
367367
platform: windows
368368

369369
integration_test_multi_python_versions_ubuntu_workspace:

.bazelignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ examples/pip_parse_vendored/bazel-pip_parse_vendored
2626
examples/pip_repository_annotations/bazel-pip_repository_annotations
2727
examples/py_proto_library/bazel-py_proto_library
2828
gazelle/bazel-gazelle
29+
gazelle/examples/bzlmod_build_file_generation/bazel-bin
30+
gazelle/examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation
31+
gazelle/examples/bzlmod_build_file_generation/bazel-out
32+
gazelle/examples/bzlmod_build_file_generation/bazel-testlog
2933
tests/integration/compile_pip_requirements/bazel-compile_pip_requirements
3034
tests/integration/ignore_root_user_error/bazel-ignore_root_user_error
3135
tests/integration/local_toolchains/bazel-local_toolchains

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ query --deleted_packages=examples/build_file_generation,examples/build_file_gene
99

1010
test --test_output=errors
1111

12+
common --deleted_packages=gazelle/examples/bzlmod_build_file_generation
13+
common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/runfiles
14+
1215
# Do NOT implicitly create empty __init__.py files in the runfiles tree.
1316
# By default, these are created in every directory containing Python source code
1417
# or shared libraries, and every parent directory of those directories,

.bcr/gazelle/presubmit.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
bcr_test_module:
16-
module_path: "../examples/bzlmod_build_file_generation"
16+
module_path: "examples/bzlmod_build_file_generation"
1717
matrix:
1818
platform: ["debian11", "macos", "ubuntu2004", "windows"]
1919
# last_rc is to get latest 8.x release. Replace with 8.x when available.
@@ -23,6 +23,8 @@ bcr_test_module:
2323
name: "Run test module"
2424
platform: ${{ platform }}
2525
bazel: ${{ bazel }}
26+
shell_commands:
27+
- "echo 'common --override_module=rules_python=' >> .bazelrc"
2628
build_targets:
2729
- "//..."
2830
- ":modules_map"

.github/workflows/create_archive_and_notes.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ set -o nounset
1717
set -o pipefail
1818
set -o errexit
1919

20+
set -x
21+
22+
TAG=$1
23+
if [ -z "$TAG" ]; then
24+
echo "ERROR: TAG env var must be set"
25+
exit 1
26+
fi
27+
# If the workflow checks out one commit, but is releasing another
28+
git fetch origin tag "$TAG"
29+
# Update our local state so the grep command below searches what we expect
30+
git checkout "$TAG"
31+
2032
set -x
2133
# Exclude dot directories, specifically, this file so that we don't
2234
# find the substring we're looking for in our own file.
@@ -34,14 +46,11 @@ if [[ $grep_exit_code -eq 0 ]]; then
3446
exit 1
3547
fi
3648

37-
# Set by GH actions, see
38-
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
39-
TAG=${GITHUB_REF_NAME}
4049
# A prefix is added to better match the GitHub generated archives.
4150
PREFIX="rules_python-${TAG}"
4251
ARCHIVE="rules_python-$TAG.tar.gz"
43-
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
44-
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
52+
git archive --format=tar "--prefix=${PREFIX}/" "$TAG" | gzip > "$ARCHIVE"
53+
SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')
4554

4655
cat > release_notes.txt << EOF
4756

.github/workflows/publish.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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: bazel-contrib/bazel-central-registry
29+
attest: false
30+
permissions:
31+
contents: write
32+
secrets:
33+
# Necessary to push to the BCR fork, and to open a pull request against a registry
34+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release.yml

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,60 @@ on:
2121
- "*.*.*"
2222
workflow_dispatch:
2323
inputs:
24+
tag_name:
25+
description: "release tag: tag that will be released"
26+
required: true
27+
type: string
2428
publish_to_pypi:
2529
description: 'Publish to PyPI'
2630
required: true
2731
type: boolean
2832
default: true
33+
secrets:
34+
publish_token:
35+
required: false
2936

3037
jobs:
31-
build:
38+
release:
39+
name: Release
3240
runs-on: ubuntu-latest
3341
steps:
3442
- name: Checkout
3543
uses: actions/checkout@v5
44+
with:
45+
ref: ${{ github.ref_name }}
3646
- name: Create release archive and notes
37-
run: .github/workflows/create_archive_and_notes.sh
38-
- name: Publish wheel dist
39-
if: github.event_name == 'push' || github.event.inputs.publish_to_pypi
40-
env:
41-
# This special value tells pypi that the user identity is supplied within the token
42-
TWINE_USERNAME: __token__
43-
# Note, the PYPI_API_TOKEN is for the rules-python pypi user, added by @rickylev on
44-
# https://github.com/bazel-contrib/rules_python/settings/secrets/actions
45-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
46-
run: bazel run --stamp --embed_label=${{ github.ref_name }} //python/runfiles:wheel.publish
47+
run: .github/workflows/create_archive_and_notes.sh ${{ inputs.tag_name || github.ref_name }}
4748
- name: Release
4849
uses: softprops/action-gh-release@v2
4950
with:
5051
# Use GH feature to populate the changelog automatically
5152
generate_release_notes: true
5253
body_path: release_notes.txt
53-
prerelease: ${{ contains(github.ref, '-rc') }}
54+
prerelease: ${{ contains( (inputs.tag_name || github.ref), '-rc') }}
5455
fail_on_unmatched_files: true
5556
files: rules_python-*.tar.gz
57+
tag_name: ${{ inputs.tag_name || github.ref_name }}
58+
59+
publish_bcr:
60+
needs: release
61+
uses: ./.github/workflows/publish.yml
62+
with:
63+
tag_name: ${{ inputs.tag_name || github.ref_name }}
64+
secrets:
65+
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}
66+
67+
publish_pypi:
68+
# We just want publish_pypi last, since once uploaded, it can't be changed.
69+
name: Publish runfiles to PyPI
70+
needs: publish_bcr
71+
runs-on: ubuntu-latest
72+
steps:
73+
- if: github.event_name == 'push' || github.event.inputs.publish_to_pypi
74+
env:
75+
# This special value tells pypi that the user identity is supplied within the token
76+
TWINE_USERNAME: __token__
77+
# Note, the PYPI_API_TOKEN is for the rules-python pypi user, added by @rickylev on
78+
# https://github.com/bazel-contrib/rules_python/settings/secrets/actions
79+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
80+
run: bazel run --stamp --embed_label=${{ inputs.tag_name || github.ref_name }} //python/runfiles:wheel.publish

docs/api/rules_python/python/config_settings/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Values:
4141

4242
This flag replaces the Bazel builtin `--build_python_zip` flag.
4343

44-
:::{versionadded} VERSION_NEXT_FEATURE
44+
:::{versionadded} 1.7.0
4545
:::
4646
::::
4747

@@ -62,7 +62,7 @@ Values;
6262
This flag replaces the Bazel builtin
6363
`--experimental_python_import_all_repositories` flag.
6464

65-
:::{versionadded} VERSION_NEXT_FEATURE
65+
:::{versionadded} 1.7.0
6666
:::
6767
::::
6868

@@ -75,11 +75,11 @@ be removed.
7575

7676
This flag replaces the Bazel builtin `--python_path` flag.
7777

78-
:::{deprecated} VERSION_NEXT_FEATURE
78+
:::{deprecated} 1.7.0
7979
Use toolchains instead.
8080
:::
8181

82-
:::{versionadded} VERSION_NEXT_FEATURE
82+
:::{versionadded} 1.7.0
8383
:::
8484
::::
8585

@@ -111,7 +111,7 @@ Values:
111111
This flag replaces the Bazel builtin
112112
`--incompatible_default_to_explicit_init_py` flag.
113113

114-
:::{versionadded} VERSION_NEXT_FEATURE
114+
:::{versionadded} 1.7.0
115115
:::
116116
::::
117117

examples/bzlmod_build_file_generation/other_module/MODULE.bazel

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

gazelle/.bazelignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
bazel-bin
2+
bazel-gazelle
3+
bazel-out
4+
bazel-testlogs
5+
examples/bzlmod_build_file_generation/bazel-bin
6+
examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation
7+
examples/bzlmod_build_file_generation/bazel-out
8+
examples/bzlmod_build_file_generation/bazel-testlog

0 commit comments

Comments
 (0)