|
20 | 20 | description: | |
21 | 21 | The version to use when creating the release. |
22 | 22 |
|
23 | | - This must be a valid version specifier (see PEP 440), |
| 23 | + This must be a valid version specifier |
| 24 | + (see PEP 440 -- https://peps.python.org/pep-0440/), |
24 | 25 | but the workflow itself doesn't currently validate the version. |
25 | 26 |
|
26 | 27 | The version can be referenced in several configuration variables |
|
41 | 42 |
|
42 | 43 | env: |
43 | 44 | PYTHON_VERSION: "3.13" |
44 | | - UV_VERSION: "0.10.6" |
| 45 | + UV_VERSION: "0.11.2" |
45 | 46 | PANDOC_VERSION: "3.8.3" |
46 | 47 | CHECK_JSONSCHEMA_REQUIREMENTS: | |
47 | | - attrs==25.4.0 ; python_version == "3.13" |
| 48 | + attrs==26.1.0 ; python_version == "3.13" |
48 | 49 | certifi==2026.2.25 ; python_version == "3.13" |
49 | | - charset-normalizer==3.4.4 ; python_version == "3.13" |
50 | | - check-jsonschema==0.36.2 ; python_version == "3.13" |
| 50 | + charset-normalizer==3.4.6 ; python_version == "3.13" |
| 51 | + check-jsonschema==0.37.1 ; python_version == "3.13" |
51 | 52 | click==8.3.1 ; python_version == "3.13" |
52 | 53 | colorama==0.4.6 ; python_version == "3.13" and platform_system == "Windows" |
53 | 54 | idna==3.11 ; python_version == "3.13" |
54 | 55 | jsonschema-specifications==2025.9.1 ; python_version == "3.13" |
55 | 56 | jsonschema==4.26.0 ; python_version == "3.13" |
56 | 57 | referencing==0.37.0 ; python_version == "3.13" |
57 | 58 | regress==2025.10.1 ; python_version == "3.13" |
58 | | - requests==2.32.5 ; python_version == "3.13" |
| 59 | + requests==2.33.0 ; python_version == "3.13" |
59 | 60 | rpds-py==0.30.0 ; python_version == "3.13" |
60 | 61 | ruamel-yaml==0.19.1 ; python_version == "3.13" |
61 | 62 | urllib3==2.6.3 ; python_version == "3.13" |
62 | 63 | TOX_REQUIREMENTS: | |
63 | | - cachetools==7.0.1 ; python_version == "3.13" |
| 64 | + cachetools==7.0.5 ; python_version == "3.13" |
64 | 65 | colorama==0.4.6 ; python_version == "3.13" |
65 | 66 | distlib==0.4.0 ; python_version == "3.13" |
66 | | - filelock==3.24.3 ; python_version == "3.13" |
| 67 | + filelock==3.25.2 ; python_version == "3.13" |
67 | 68 | packaging==26.0 ; python_version == "3.13" |
68 | | - platformdirs==4.9.2 ; python_version == "3.13" |
| 69 | + platformdirs==4.9.4 ; python_version == "3.13" |
69 | 70 | pluggy==1.6.0 ; python_version == "3.13" |
70 | 71 | pyproject-api==1.10.0 ; python_version == "3.13" |
71 | | - python-discovery==1.0.0 ; python_version == "3.13" |
| 72 | + python-discovery==1.2.1 ; python_version == "3.13" |
| 73 | + tomli-w==1.2.0 ; python_version == "3.13" |
72 | 74 | tox-gh==1.7.1 ; python_version == "3.13" |
73 | | - tox-uv-bare==1.33.0 ; python_version == "3.13" |
74 | | - tox-uv==1.33.0 ; python_version == "3.13" |
75 | | - tox==4.46.3 ; python_version == "3.13" |
76 | | - uv==0.10.6 ; python_version == "3.13" |
77 | | - virtualenv==21.0.0 ; python_version == "3.13" |
| 75 | + tox-uv-bare==1.33.4 ; python_version == "3.13" |
| 76 | + tox-uv==1.33.4 ; python_version == "3.13" |
| 77 | + tox==4.51.0 ; python_version == "3.13" |
| 78 | + uv==0.11.2 ; python_version == "3.13" |
| 79 | + virtualenv==21.2.0 ; python_version == "3.13" |
78 | 80 |
|
79 | 81 | # These values are used when a config value is not specified. |
80 | 82 | default-branch-from: "main" |
@@ -241,6 +243,7 @@ jobs: |
241 | 243 | - name: "Checkout the repository" |
242 | 244 | uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2 |
243 | 245 | with: |
| 246 | + persist-credentials: "false" |
244 | 247 | ref: "${{ fromJSON(inputs.config).branch-from || env.default-branch-from }}" |
245 | 248 | fetch-depth: 0 |
246 | 249 |
|
@@ -400,14 +403,91 @@ jobs: |
400 | 403 | if __name__ == "__main__": |
401 | 404 | sys.exit(main()) |
402 | 405 |
|
403 | | - - name: "Push a new branch" |
| 406 | + - name: "Compute versioned variables" |
| 407 | + shell: "python" |
404 | 408 | env: |
405 | 409 | VERSION: "${{ inputs.version }}" |
| 410 | + DEFAULT_BRANCH_NAME: "${{ env.default-branch-name }}" |
| 411 | + BRANCH_NAME: "${{ fromJSON(inputs.config).branch-name }}" |
| 412 | + DEFAULT_PR_TITLE: "${{ env.default-pr-title }}" |
| 413 | + PR_TITLE: "${{ fromJSON(inputs.config).pr-title }}" |
| 414 | + # Creates new environment variables: |
| 415 | + # |
| 416 | + # * COMPUTED_BRANCH_NAME |
| 417 | + # * COMPUTED_PR_TITLE |
| 418 | + # |
| 419 | + run: | |
| 420 | + # This file is a part of the Globus GitHub Workflows project. |
| 421 | + # https://github.com/globus/workflows |
| 422 | + # Copyright 2021-2026 Globus <support@globus.org> |
| 423 | + # Copyright 2024-2026 Kurt McKee <contactme@kurtmckee.org> |
| 424 | + # SPDX-License-Identifier: MIT |
| 425 | +
|
| 426 | + import os |
| 427 | + import sys |
| 428 | +
|
| 429 | + RC_SUCCESS = 0 |
| 430 | + RC_FAILURE = 1 |
| 431 | +
|
| 432 | + mandatory_environment_variables = { |
| 433 | + "BRANCH_NAME", |
| 434 | + "DEFAULT_BRANCH_NAME", |
| 435 | + "GITHUB_ENV", |
| 436 | + "VERSION", |
| 437 | + } |
| 438 | +
|
| 439 | +
|
| 440 | + def main() -> int: |
| 441 | + # Ensure mandatory environment variables are present. |
| 442 | + if missing_keys := (mandatory_environment_variables - os.environ.keys()): |
| 443 | + for missing_key in missing_keys: |
| 444 | + print(f"`{missing_key}` is a mandatory environment variable.") |
| 445 | + return RC_FAILURE |
| 446 | +
|
| 447 | + # Branch name |
| 448 | + branch_name = os.environ["BRANCH_NAME"] |
| 449 | + if branch_name: |
| 450 | + version = os.environ["VERSION"] |
| 451 | + computed_branch_name = branch_name.replace("$VERSION", version) |
| 452 | + else: |
| 453 | + computed_branch_name = os.environ["DEFAULT_BRANCH_NAME"] |
| 454 | + with open(os.environ["GITHUB_ENV"], "a") as file: |
| 455 | + file.write(f"COMPUTED_BRANCH_NAME={computed_branch_name}\n") |
| 456 | +
|
| 457 | + # PR title |
| 458 | + pr_title = os.environ["PR_TITLE"] |
| 459 | + if pr_title: |
| 460 | + version = os.environ["VERSION"] |
| 461 | + computed_pr_title = pr_title.replace("$VERSION", version) |
| 462 | + else: |
| 463 | + computed_pr_title = os.environ["DEFAULT_PR_TITLE"] |
| 464 | + with open(os.environ["GITHUB_ENV"], "a") as file: |
| 465 | + file.write(f"COMPUTED_PR_TITLE={computed_pr_title}\n") |
| 466 | +
|
| 467 | + return RC_SUCCESS |
| 468 | +
|
| 469 | +
|
| 470 | + if __name__ == "__main__": |
| 471 | + sys.exit(main()) |
| 472 | +
|
| 473 | + - name: "Push a new branch" |
| 474 | + env: |
406 | 475 | GH_TOKEN: "${{ github.token }}" |
407 | | - COMMIT_TITLE: "${{ fromJSON(inputs.config).commit-title || env.default-commit-title }}" |
| 476 | + COMPUTED_BRANCH_NAME: "${{ env.COMPUTED_BRANCH_NAME }}" |
408 | 477 | run: | |
409 | | - git push origin HEAD:"${{ fromJSON(inputs.config).branch-name || env.default-branch-name }}" |
410 | | - gh api graphql --input "${{ runner.temp }}/graphql-input.json" |
| 478 | + # `gh api` is required because `git` has no permissions. |
| 479 | +
|
| 480 | + # Create the branch on the server. |
| 481 | + gh api \ |
| 482 | + --method POST \ |
| 483 | + -H "Accept: application/vnd.github+json" \ |
| 484 | + -H "X-GitHub-Api-Version: 2026-03-10" \ |
| 485 | + "/repos/${GITHUB_REPOSITORY}/git/refs" \ |
| 486 | + --field "ref=refs/heads/${COMPUTED_BRANCH_NAME}" \ |
| 487 | + --field "sha=${GITHUB_SHA}" |
| 488 | +
|
| 489 | + # Push a new commit to the branch. |
| 490 | + gh api graphql --input "${RUNNER_TEMP}/graphql-input.json" |
411 | 491 |
|
412 | 492 | - name: "Generate the PR body" |
413 | 493 | env: |
@@ -446,12 +526,14 @@ jobs: |
446 | 526 |
|
447 | 527 | - name: "Create a PR" |
448 | 528 | env: |
449 | | - VERSION: "${{ inputs.version }}" |
450 | 529 | GH_TOKEN: "${{ github.token }}" |
| 530 | + COMPUTED_BRANCH_NAME: "${{ env.COMPUTED_BRANCH_NAME }}" |
| 531 | + COMPUTED_PR_TITLE: "${{ env.COMPUTED_PR_TITLE }}" |
| 532 | + PR_BASE: "${{ fromJSON(inputs.config).pr-base || env.default-pr-base }}" |
451 | 533 | run: | |
452 | 534 | gh pr create \ |
453 | 535 | --draft \ |
454 | | - --head "${{ fromJSON(inputs.config).branch-name || env.default-branch-name }}" \ |
455 | | - --base "${{ fromJSON(inputs.config).pr-base || env.default-pr-base }}" \ |
456 | | - --title "${{ fromJSON(inputs.config).pr-title || env.default-pr-title }}" \ |
| 536 | + --head "${COMPUTED_BRANCH_NAME}" \ |
| 537 | + --base "${PR_BASE}" \ |
| 538 | + --title "${COMPUTED_PR_TITLE}" \ |
457 | 539 | --body-file "${RUNNER_TEMP}/pr-body.gfm" |
0 commit comments