Skip to content

Commit 9ed2595

Browse files
paritytech-release-backport-bot[bot]BDevParityEgorPopelyaevParityReleases
authored
[stable2603] Backport #11056 (#11127)
Backport #11056 into `stable2603` from BDevParity. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> --------- Co-authored-by: BDevParity <bruno.devic@parity.io> Co-authored-by: EgorPopelyaev <egor@parity.io> Co-authored-by: ParityReleases <release-team@parity.io>
1 parent 03380f1 commit 9ed2595

File tree

3 files changed

+316
-13
lines changed

3 files changed

+316
-13
lines changed

.github/workflows/release-60_post-crates-release-activities.yml

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ permissions:
2727
pull-requests: write
2828

2929
jobs:
30+
#check-synchronization:
31+
# uses: paritytech-release/sync-workflows/.github/workflows/check-synchronization.yml@main
32+
#secrets:
33+
# fork_writer_app_key: ${{ secrets.UPSTREAM_CONTENT_SYNC_APP_KEY }}
34+
3035
set-image:
36+
#needs: [ check-synchronization ]
37+
#if: needs.check-synchronization.outputs.checks_passed == 'true'
3138
runs-on: ubuntu-latest
3239
outputs:
3340
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
@@ -283,9 +290,18 @@ jobs:
283290
echo "No changes to commit"
284291
fi
285292
293+
- name: Generate token for paritytech/polkadot-sdk
294+
id: generate_write_token
295+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
296+
with:
297+
app-id: ${{ vars.POLKADOT_SDK_RELEASE_RW_APP_ID }}
298+
private-key: ${{ secrets.POLKADOT_SDK_RELEASE_RW_APP_KEY }}
299+
owner: paritytech
300+
repositories: polkadot-sdk
301+
286302
- name: Create Pull Request to base release branch
287303
env:
288-
GH_TOKEN: ${{ github.token }}
304+
GH_TOKEN: ${{ steps.generate_write_token.outputs.token }}
289305
shell: bash
290306
run: |
291307
BRANCH_NAME="${{ github.ref_name }}"
@@ -300,15 +316,30 @@ jobs:
300316
BASE_RELEASE="$FULL_RELEASE"
301317
fi
302318
319+
TARGET_REPO="paritytech/polkadot-sdk"
320+
321+
# Determine if running from a fork or the main repo
322+
if [ "${{ github.repository }}" = "$TARGET_REPO" ]; then
323+
# Same-repo PR: head is just the branch name
324+
PR_HEAD="$BRANCH_NAME"
325+
EXTRA_FLAGS=""
326+
else
327+
# Cross-fork PR: head needs the fork owner prefix
328+
FORK_OWNER="${{ github.repository_owner }}"
329+
PR_HEAD="${FORK_OWNER}:${BRANCH_NAME}"
330+
EXTRA_FLAGS="--no-maintainer-edit"
331+
fi
332+
303333
# Check if PR already exists
304-
EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --base "$BASE_RELEASE" --json number --jq '.[0].number')
334+
EXISTING_PR=$(gh pr list --repo "$TARGET_REPO" --head "$PR_HEAD" --base "$BASE_RELEASE" --json number --jq '.[0].number')
305335
306336
if [ -n "$EXISTING_PR" ]; then
307337
echo "✅ PR #$EXISTING_PR already exists for this branch"
308-
echo "PR URL: $(gh pr view $EXISTING_PR --json url --jq '.url')"
338+
echo "PR URL: $(gh pr view $EXISTING_PR --repo "$TARGET_REPO" --json url --jq '.url')"
309339
else
310-
echo "Creating PR from $BRANCH_NAME to $BASE_RELEASE..."
340+
echo "Creating PR from $PR_HEAD to $BASE_RELEASE in $TARGET_REPO..."
311341
gh pr create \
342+
--repo "$TARGET_REPO" \
312343
--title "[${BASE_RELEASE}] Post crates release activities for $FULL_RELEASE" \
313344
--body "Automated PR containing post-crates-release activities:
314345
- NODE_VERSION bumps (if selected)
@@ -317,23 +348,33 @@ jobs:
317348
- Taplo formatting
318349
- PRDocs reorganization (if prdocs exist)" \
319350
--base "$BASE_RELEASE" \
320-
--head "$BRANCH_NAME"
321-
echo "✅ PR created successfully"
351+
--head "$PR_HEAD" \
352+
$EXTRA_FLAGS
353+
echo "PR created successfully"
322354
fi
323355
324356
- name: Add comment about spec_version
325357
env:
326-
GH_TOKEN: ${{ github.token }}
358+
GH_TOKEN: ${{ steps.generate_write_token.outputs.token }}
327359
shell: bash
328360
run: |
329361
BRANCH_NAME="${{ github.ref_name }}"
362+
TARGET_REPO="paritytech/polkadot-sdk"
363+
364+
# Match the head format used when creating the PR
365+
if [ "${{ github.repository }}" = "$TARGET_REPO" ]; then
366+
PR_HEAD="$BRANCH_NAME"
367+
else
368+
FORK_OWNER="${{ github.repository_owner }}"
369+
PR_HEAD="${FORK_OWNER}:${BRANCH_NAME}"
370+
fi
330371
331-
# Find the PR number for this branch
332-
PR_NUMBER=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number')
372+
# Find the PR number for this branch in the upstream repo
373+
PR_NUMBER=$(gh pr list --repo "$TARGET_REPO" --head "$PR_HEAD" --json number --jq '.[0].number')
333374
334375
if [ -n "$PR_NUMBER" ]; then
335376
echo "Adding comment to PR #$PR_NUMBER..."
336-
gh pr comment "$PR_NUMBER" --body "⚠️ **Reminder:** spec_version is not bumped automatically as part of this flow. Please ensure it is updated manually if required."
377+
gh pr comment "$PR_NUMBER" --repo "$TARGET_REPO" --body "⚠️ **Reminder:** If spec_version was not bumped automatically as part of this flow. Please ensure it is updated manually if required."
337378
else
338-
echo "WARNING: Could not find PR for branch $BRANCH_NAME"
379+
echo "⚠️ WARNING: Could not find PR for branch $PR_HEAD"
339380
fi
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
name: Release - Publish Crates
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_name:
7+
description: 'Release name (e.g., stable2509-3). Base branch is derived by removing the last -N suffix.'
8+
required: true
9+
type: string
10+
registry:
11+
description: 'Registry to publish crates to'
12+
required: true
13+
type: choice
14+
options:
15+
- staging.crates.io
16+
- crates.io
17+
default: staging.crates.io
18+
is_patch:
19+
description: 'Is this a patch release? (Set to false for new stable releases)'
20+
required: true
21+
type: boolean
22+
default: true
23+
dry_run:
24+
description: 'Dry run - do not actually publish crates'
25+
required: true
26+
type: boolean
27+
default: true
28+
29+
permissions:
30+
contents: write
31+
32+
jobs:
33+
check-synchronization:
34+
uses: paritytech-release/sync-workflows/.github/workflows/check-synchronization.yml@main
35+
secrets:
36+
fork_writer_app_key: ${{ secrets.UPSTREAM_CONTENT_SYNC_APP_KEY }}
37+
38+
set-image:
39+
needs: [ check-synchronization ]
40+
if: needs.check-synchronization.outputs.checks_passed == 'true'
41+
runs-on: ubuntu-latest
42+
outputs:
43+
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
47+
48+
- id: set_image
49+
run: cat .github/env >> $GITHUB_OUTPUT
50+
51+
publish-crates:
52+
needs: set-image
53+
runs-on: ubuntu-latest
54+
environment: release
55+
env:
56+
PGP_KMS_KEY: ${{ secrets.PGP_KMS_SIGN_COMMITS_KEY }}
57+
PGP_KMS_HASH: ${{ secrets.PGP_KMS_HASH }}
58+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
59+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
60+
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
61+
container:
62+
image: ${{ needs.set-image.outputs.IMAGE }}
63+
64+
steps:
65+
- name: Install pgpkms
66+
run: |
67+
# Install pgpkms that is used to sign commits
68+
pip install git+https://github.com/paritytech-release/pgpkms.git@6cb1cecce1268412189b77e4b130f4fa248c4151
69+
70+
- name: Derive stable branch from release name
71+
id: derive_branch
72+
shell: bash
73+
run: |
74+
RELEASE_NAME="${{ inputs.release_name }}"
75+
echo "Release name: $RELEASE_NAME"
76+
77+
# Extract stable branch by removing the last -N suffix
78+
# e.g., stable2509-3 -> stable2509
79+
if [[ "$RELEASE_NAME" =~ ^(.+)-[0-9]+$ ]]; then
80+
STABLE_BRANCH="${BASH_REMATCH[1]}"
81+
else
82+
# If no suffix, use the release name as-is (first release)
83+
STABLE_BRANCH="$RELEASE_NAME"
84+
fi
85+
86+
echo "Stable branch: $STABLE_BRANCH"
87+
echo "STABLE_BRANCH=$STABLE_BRANCH" >> $GITHUB_OUTPUT
88+
89+
echo "CRATES_RELEASE_BRANCH=post-crates-release-$RELEASE_NAME" >> $GITHUB_OUTPUT
90+
91+
- name: Checkout stable branch
92+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
93+
with:
94+
ref: ${{ steps.derive_branch.outputs.STABLE_BRANCH }}
95+
fetch-depth: 0
96+
97+
- name: Import GPG keys
98+
shell: bash
99+
run: |
100+
. ./.github/scripts/common/lib.sh
101+
import_gpg_keys
102+
103+
- name: Configure git
104+
shell: bash
105+
run: |
106+
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
107+
git config --global commit.gpgsign true
108+
PGPKMS_PATH=$(which pgpkms-git)
109+
echo "Using pgpkms-git at: $PGPKMS_PATH"
110+
git config --global gpg.program "$PGPKMS_PATH"
111+
git config --global user.name "ParityReleases"
112+
git config --global user.email "release-team@parity.io"
113+
git config --global user.signingKey "D8018FBB3F534D866A45998293C5FB5F6A367B51"
114+
115+
- name: Create or switch to release branch
116+
shell: bash
117+
run: |
118+
CRATES_RELEASE_BRANCH="${{ steps.derive_branch.outputs.CRATES_RELEASE_BRANCH }}"
119+
120+
if git rev-parse --verify -q "$CRATES_RELEASE_BRANCH" &>/dev/null; then
121+
echo "Branch $CRATES_RELEASE_BRANCH already exists, switching to it"
122+
git checkout "$CRATES_RELEASE_BRANCH"
123+
else
124+
echo "Creating branch: $CRATES_RELEASE_BRANCH"
125+
git checkout -b "$CRATES_RELEASE_BRANCH"
126+
fi
127+
echo "On branch $CRATES_RELEASE_BRANCH"
128+
129+
- name: Install Rust 1.93
130+
shell: bash
131+
run: |
132+
rustup install 1.93
133+
rustup default 1.93
134+
echo "Rust version:"
135+
rustc --version
136+
cargo --version
137+
138+
- name: Rust Cache
139+
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
140+
with:
141+
cache-on-failure: true
142+
143+
- name: Install parity-publish
144+
run: |
145+
apt-get update && apt-get install -y --no-install-recommends libcurl4-openssl-dev pkg-config
146+
cargo install parity-publish@0.10.10 --locked -q
147+
148+
- name: Run parity-publish plan
149+
run: |
150+
echo "Running parity-publish plan..."
151+
parity-publish plan --prdoc prdoc
152+
153+
- name: Save Plan.toml diff
154+
if: inputs.is_patch
155+
run: |
156+
RELEASE_NAME="${{ inputs.release_name }}"
157+
mkdir -p release-artifacts
158+
159+
echo "Saving Plan.toml diff..."
160+
git diff Plan.toml > "release-artifacts/changed_crates_${RELEASE_NAME}.txt"
161+
162+
echo "Plan.toml changes:"
163+
cat "release-artifacts/changed_crates_${RELEASE_NAME}.txt"
164+
165+
- name: Parse crate names for release notes
166+
if: inputs.is_patch
167+
shell: bash
168+
run: |
169+
RELEASE_NAME="${{ inputs.release_name }}"
170+
171+
echo "Parsing crate names..."
172+
python3 scripts/release/parse-crates-names.py \
173+
"release-artifacts/changed_crates_${RELEASE_NAME}.txt" \
174+
scripts/release/templates/crates_list.md.tera
175+
176+
echo "Crates list:"
177+
cat scripts/release/templates/crates_list.md.tera
178+
179+
- name: Commit Plan.toml and crates list
180+
shell: bash
181+
run: |
182+
. ./.github/scripts/release/release_lib.sh
183+
184+
git add Plan.toml
185+
if [ "${{ inputs.is_patch }}" = true ]; then
186+
git add scripts/release/templates/crates_list.md.tera
187+
fi
188+
189+
if [[ -n $(git status --porcelain) ]]; then
190+
commit_with_message "chore: update Plan.toml and crates list for ${{ inputs.release_name }}"
191+
echo "Committed Plan.toml and crates list"
192+
else
193+
echo "No changes to commit"
194+
fi
195+
196+
- name: Run parity-publish apply
197+
run: |
198+
echo "Running parity-publish apply..."
199+
parity-publish apply
200+
201+
- name: Update Cargo.lock
202+
run: |
203+
echo "Updating Cargo.lock..."
204+
cargo update --workspace --offline || cargo update --workspace
205+
echo "Cargo.lock updated"
206+
207+
- name: Commit version bumps
208+
shell: bash
209+
run: |
210+
. ./.github/scripts/release/release_lib.sh
211+
212+
git add -A
213+
214+
if [[ -n $(git status --porcelain) ]]; then
215+
commit_with_message "chore: apply version bumps for ${{ inputs.release_name }}"
216+
echo "Committed version bumps"
217+
else
218+
echo "No changes to commit"
219+
fi
220+
221+
- name: Push release branch
222+
run: |
223+
CRATES_RELEASE_BRANCH="${{ steps.derive_branch.outputs.CRATES_RELEASE_BRANCH }}"
224+
echo "Pushing branch $CRATES_RELEASE_BRANCH..."
225+
git push origin "$CRATES_RELEASE_BRANCH"
226+
echo "Successfully pushed $CRATES_RELEASE_BRANCH"
227+
228+
- name: Configure cargo registry
229+
shell: bash
230+
run: |
231+
REGISTRY="${{ inputs.registry }}"
232+
echo "Configuring cargo for $REGISTRY..."
233+
mkdir -p ~/.cargo
234+
235+
if [ "$REGISTRY" = "staging.crates.io" ]; then
236+
cat >> ~/.cargo/config.toml << 'EOF'
237+
[registries.crates-io]
238+
index = "sparse+https://index.staging.crates.io/"
239+
EOF
240+
else
241+
echo "Using default crates.io registry"
242+
fi
243+
244+
echo "Cargo config:"
245+
cat ~/.cargo/config.toml || echo "(using defaults)"
246+
247+
- name: Publish crates
248+
shell: bash
249+
env:
250+
PARITY_PUBLISH_CRATESIO_TOKEN: ${{ inputs.registry == 'staging.crates.io' && secrets.STAGING_CRATES_IO_API_TOKEN || secrets.CRATES_IO_API_TOKEN }}
251+
run: |
252+
DRY_RUN="${{ inputs.dry_run }}"
253+
REGISTRY="${{ inputs.registry }}"
254+
255+
if [ "$DRY_RUN" = true ]; then
256+
echo "DRY RUN - Not actually publishing crates"
257+
echo "Target registry: $REGISTRY"
258+
parity-publish apply -p -d
259+
else
260+
echo "Publishing crates to $REGISTRY..."
261+
parity-publish apply -p
262+
echo "Crates published successfully to $REGISTRY!"
263+
fi

scripts/release/replace-all-path-deps.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ find . -name "Cargo.toml" \
1414
# Find and replace path dependencies with "workspace = true"
1515
awk '
1616
BEGIN { in_section = 0 }
17-
/^\[dependencies\]/ { in_section = 1; print; next }
18-
/^\[dev-dependencies\]/ { in_section = 2; print; next }
17+
/^\[.*dependencies\]/ { in_section = 1; print; next }
1918
/^\[.*\]/ { in_section = 0; print; next }
2019
2120
{

0 commit comments

Comments
 (0)