Skip to content

Commit c3813a5

Browse files
authored
add a workflow for preparing releases (#28486)
this is primarily useful for testing the sts token exchange in a non-load bearing environment ahead of merging #28484 , but may be useful for maintainers :) `automations` environment has been created and `STS_API_URL` secret set
1 parent 00948c0 commit c3813a5

4 files changed

Lines changed: 125 additions & 1 deletion

File tree

‎.github/secure-token-service.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": 2,
3+
"repositories": {
4+
"ruff": {
5+
"name": "astral-sh/ruff",
6+
"id": 523043277,
7+
"oidc_subject": "legacy"
8+
}
9+
},
10+
"rules": [
11+
{
12+
"caller": "ruff",
13+
"environment": "automations",
14+
"caller_workflow": "release-prepare.yml",
15+
"on": ["workflow_dispatch"],
16+
"permissions": { "contents": "write", "pull_requests": "write" },
17+
"target": "ruff"
18+
}
19+
]
20+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Bump the Ruff version and create a pull request.
2+
name: "Prepare release"
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: "The version to set (overrides detection)"
9+
required: false
10+
type: string
11+
12+
permissions: {}
13+
14+
env:
15+
UV_LOCKED: 1
16+
17+
jobs:
18+
prepare-release:
19+
if: github.repository == 'astral-sh/ruff' && github.ref == 'refs/heads/main'
20+
runs-on: ${{ github.repository == 'astral-sh/ruff' && 'github-ubuntu-24.04-x86_64-4' || 'ubuntu-latest' }}
21+
environment: automations
22+
permissions:
23+
contents: read
24+
id-token: write # for the credential broker
25+
steps:
26+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
27+
with:
28+
fetch-depth: 0
29+
persist-credentials: false
30+
31+
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
32+
with:
33+
version: "0.12.11"
34+
enable-cache: true
35+
36+
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
37+
with:
38+
save-if: false
39+
40+
- name: "Get Ruff token"
41+
id: token
42+
uses: open-security-tools/ost-simple-sts@9e012247e07c39080fb6a832dbfbcfeacebc19c4
43+
with:
44+
exchange-url: ${{ secrets.STS_API_URL }}/exchange
45+
audience: ${{ secrets.STS_API_URL }}
46+
repository: astral-sh/ruff
47+
permissions: |
48+
contents: write
49+
pull_requests: write
50+
51+
- name: "Configure Git"
52+
run: |
53+
git config user.name "astral-automations-bot[bot]"
54+
git config user.email "305554984+astral-automations-bot[bot]@users.noreply.github.com"
55+
56+
- name: "Bump version"
57+
run: |
58+
if [ -n "$INPUT_VERSION" ]; then
59+
./scripts/release.sh --version "$INPUT_VERSION"
60+
else
61+
./scripts/release.sh
62+
fi
63+
env:
64+
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
65+
INPUT_VERSION: ${{ inputs.version }}
66+
67+
- name: "Create release branch"
68+
run: |
69+
version="$(uv version --short)"
70+
git switch -c "release/$version"
71+
git commit -am "Bump version to $version"
72+
73+
- name: "Create or update pull request"
74+
run: |
75+
branch="$(git branch --show-current)"
76+
git push --force \
77+
"https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \
78+
HEAD:"$branch"
79+
80+
pull_request="$(
81+
gh pr list \
82+
--base main \
83+
--head "$branch" \
84+
--state open \
85+
--json url \
86+
--jq '.[0].url'
87+
)"
88+
if [ -n "$pull_request" ]; then
89+
printf '%s\n' "$pull_request"
90+
else
91+
gh pr create \
92+
--base main \
93+
--head "$branch" \
94+
--fill-first
95+
fi
96+
env:
97+
GITHUB_TOKEN: ${{ steps.token.outputs.token }}

‎CONTRIBUTING.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,13 @@ even patch releases may contain [non-backwards-compatible changes](https://semve
489489

490490
Commit each step of this process separately for easier review.
491491

492+
Optionally, run the [Prepare release workflow](https://github.com/astral-sh/ruff/actions/workflows/release-prepare.yml)
493+
to generate the version updates and changelog and open a pull request. Leave `version` blank to detect
494+
the next version from pull request labels, or provide an explicit version. The generated changelog
495+
still needs manual review and editing. Check out the generated branch and continue with the changelog
496+
review and remaining preparation steps below. To prepare the release locally, start with
497+
`./scripts/release.sh`.
498+
492499
1. Run `./scripts/release.sh`; this command will:
493500

494501
- Generate a temporary virtual environment with `rooster`

‎scripts/release.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ uv run --script "$project_root/scripts/generate-crate-readmes.py"
2222

2323
echo "Updating lockfiles..."
2424
cargo update -p ruff
25-
uv lock
25+
uv lock --no-locked
2626

2727
echo "Checking crates.io publish setup..."
2828
crates_policies="$(mktemp -d)"

0 commit comments

Comments
 (0)