Skip to content

Release - Post Crates Release Activities #64

Release - Post Crates Release Activities

Release - Post Crates Release Activities #64

name: Release - Post Crates Release Activities
on:
workflow_dispatch:
inputs:
version:
description: 'Full release version identifier (e.g., stable2512 or stable2512-2)'
required: true
type: string
bump_node_version:
description: 'Bump NODE_VERSION? Select "yes" if this is the first run for this post-crates PR, "no" if re-running or if you have another reason not to bump'
required: true
type: choice
options:
- 'yes'
- 'no'
bump_spec_version:
description: 'Bump spec_version? Select "yes" to bump spec version for all runtimes, "no" if re-running or if you have another reason not to bump'
required: true
type: choice
options:
- 'yes'
- 'no'
permissions:
contents: write
pull-requests: write
jobs:
set-image:
if: ${{ github.event.inputs.version != '' && contains(fromJSON('["nprt", "ArshamTeymouri", "EgorPopelyaev", "alvicsam", "AndWeHaveAPlan", "eduardspa", "BDevParity"]'), github.actor) }}
runs-on: ubuntu-latest
outputs:
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- id: set_image
run: cat .github/env >> $GITHUB_OUTPUT
post-crates-activities:
needs: set-image
runs-on: ubuntu-latest
environment: release
env:
PGP_KMS_KEY: ${{ secrets.PGP_KMS_SIGN_COMMITS_KEY }}
PGP_KMS_HASH: ${{ secrets.PGP_KMS_HASH }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
container:
image: ${{ needs.set-image.outputs.IMAGE }}
steps:
- name: Install pgpkms
run: |
# Install pgpkms that is used to sign commits
pip install git+https://github.com/paritytech-release/pgpkms.git@dc30e487d47f53d069831a4306377a3ec32638ae
# Find and display where pgpkms-git is installed
echo "pgpkms-git location: $(which pgpkms-git)"
ls -la $(which pgpkms-git)
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Import GPG keys
shell: bash
run: |
. ./.github/scripts/common/lib.sh
import_gpg_keys
- name: Configure git
shell: bash
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
git config --global commit.gpgsign true
# Dynamically find pgpkms-git path
PGPKMS_PATH=$(which pgpkms-git)
echo "Using pgpkms-git at: $PGPKMS_PATH"
git config --global gpg.program "$PGPKMS_PATH"
git config --global user.name "ParityReleases"
git config --global user.email "release-team@parity.io"
git config --global user.signingKey "D8018FBB3F534D866A45998293C5FB5F6A367B51"
- name: Bump NODE_VERSION for polkadot
if: inputs.bump_node_version == 'yes'
run: |
echo "Bumping NODE_VERSION in polkadot..."
FILE="polkadot/node/primitives/src/lib.rs"
# Extract current NODE_VERSION
current_version=$(grep 'pub const NODE_VERSION' "$FILE" | grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"')
echo "Current version: $current_version"
# Bump patch version
new_version=$(echo "$current_version" | awk -F. '{print $1"."$2"."$3+1}')
echo "New version: $new_version"
# Update the file
sed -i.bak "s/NODE_VERSION: &'static str = \"$current_version\"/NODE_VERSION: \&'static str = \"$new_version\"/" "$FILE"
rm -f "$FILE.bak"
echo "Successfully bumped NODE_VERSION from $current_version to $new_version"
- name: Bump NODE_VERSION for polkadot-parachain and polkadot-omni-node
if: inputs.bump_node_version == 'yes'
run: |
echo "Bumping NODE_VERSION in cumulus..."
FILE="cumulus/polkadot-omni-node/lib/src/nodes/mod.rs"
# Extract current NODE_VERSION
current_version=$(grep 'pub const NODE_VERSION' "$FILE" | grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"')
echo "Current version: $current_version"
# Bump patch version
new_version=$(echo "$current_version" | awk -F. '{print $1"."$2"."$3+1}')
echo "New version: $new_version"
# Update the file
sed -i.bak "s/NODE_VERSION: &'static str = \"$current_version\"/NODE_VERSION: \&'static str = \"$new_version\"/" "$FILE"
rm -f "$FILE.bak"
echo "Successfully bumped NODE_VERSION from $current_version to $new_version"
- name: Commit NODE_VERSION bumps
if: inputs.bump_node_version == 'yes'
shell: bash
run: |
. ./.github/scripts/release/release_lib.sh
# Extract the bumped NODE_VERSION
FILE="polkadot/node/primitives/src/lib.rs"
NODE_VERSION=$(grep 'pub const NODE_VERSION' "$FILE" | grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"')
echo "Committing NODE_VERSION bump to $NODE_VERSION"
commit_with_message "Bump NODE_VERSION to $NODE_VERSION"
echo "✅ Successfully committed NODE_VERSION bump"
- name: Bump spec_version
if: inputs.bump_spec_version == 'yes'
shell: bash
run: |
. ./.github/scripts/release/release_lib.sh
FILE="polkadot/node/primitives/src/lib.rs"
NODE_VERSION=$(grep 'pub const NODE_VERSION' "$FILE" | grep -oE '"[0-9]+\.[0-9]+\.[0-9]+"' | tr -d '"')
# Determine if this is a patch release or new stable release
patch=$(echo "$NODE_VERSION" | awk -F'[.-]' '{print $3}')
if [ "$patch" -gt 0 ]; then
IS_PATCH_RELEASE="true"
printf "📋 Patch release detected (patch=$patch) - bumping spec_version patch part\n"
else
IS_PATCH_RELEASE="false"
printf "📋 New stable release detected - bumping spec_version minor part\n"
fi
runtimes_list=$(get_filtered_runtimes_list)
for f in ${runtimes_list[@]}; do
new_version=$(bump_spec_version "$f" "$IS_PATCH_RELEASE")
printf " 🔄 $f → spec_version: $new_version\n"
done
commit_with_message "Bump spec_version for $([ \"$IS_PATCH_RELEASE\" = \"true\" ] && echo \"patch\" || echo \"stable\") release"
- name: Move prdocs to release folder
shell: bash
env:
VERSION: ${{ inputs.version }}
run: |
. ./.github/scripts/release/release_lib.sh
echo "Version: $VERSION"
reorder_prdocs "$VERSION"
- name: Push changes
shell: bash
run: |
echo "Pushing changes to branch..."
git push
echo "Changes pushed successfully"
- name: Generate token
id: generate_token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
with:
app-id: ${{ secrets.RELEASE_BACKPORT_AUTOMATION_APP_ID }}
private-key: ${{ secrets.RELEASE_BACKPORT_AUTOMATION_APP_PRIVATE_KEY }}
- name: Create Pull Request to base release branch
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
BRANCH_NAME: ${{ github.ref_name }}
FULL_RELEASE: ${{ inputs.version }}
GH_REPOSITORY: ${{ github.repository }}
GH_REPOSITORY_OWNER: ${{ github.repository_owner }}
shell: bash
run: |
echo "Current branch: $BRANCH_NAME"
echo "Version: $FULL_RELEASE"
# Extract base release branch name by removing the last segment after dash
if [[ "$FULL_RELEASE" =~ ^(.+)-[^-]+$ ]]; then
BASE_RELEASE="${BASH_REMATCH[1]}"
else
BASE_RELEASE="$FULL_RELEASE"
fi
TARGET_REPO="paritytech/polkadot-sdk"
# Determine if running from a fork or the main repo
if [ "$GH_REPOSITORY" = "$TARGET_REPO" ]; then
# Same-repo PR: head is just the branch name
PR_HEAD="$BRANCH_NAME"
EXTRA_FLAGS=""
else
# Cross-fork PR: head needs the fork owner prefix
FORK_OWNER="$GH_REPOSITORY_OWNER"
PR_HEAD="${FORK_OWNER}:${BRANCH_NAME}"
EXTRA_FLAGS="--no-maintainer-edit"
fi
# Check if PR already exists
EXISTING_PR=$(gh pr list --repo "$TARGET_REPO" --head "$PR_HEAD" --base "$BASE_RELEASE" --json number --jq '.[0].number')
if [ -n "$EXISTING_PR" ]; then
echo "✅ PR #$EXISTING_PR already exists for this branch"
echo "PR URL: $(gh pr view $EXISTING_PR --repo "$TARGET_REPO" --json url --jq '.url')"
else
echo "Creating PR from $PR_HEAD to $BASE_RELEASE in $TARGET_REPO..."
gh pr create \
--repo "$TARGET_REPO" \
--title "[${BASE_RELEASE}] Post crates release activities for $FULL_RELEASE" \
--body "Automated PR containing post-crates-release activities:
- NODE_VERSION bumps (if selected)
- Path dependencies replacement
- Zepter fixes
- Taplo formatting
- PRDocs reorganization (if prdocs exist)" \
--base "$BASE_RELEASE" \
--head "$PR_HEAD" \
$EXTRA_FLAGS
echo "PR created successfully"
fi
- name: Add comment about spec_version
env:
GH_TOKEN: ${{ github.token }}
BRANCH_NAME: ${{ github.ref_name }}
GH_REPOSITORY: ${{ github.repository }}
GH_REPOSITORY_OWNER: ${{ github.repository_owner }}
shell: bash
run: |
TARGET_REPO="paritytech/polkadot-sdk"
# Match the head format used when creating the PR
if [ "$GH_REPOSITORY" = "$TARGET_REPO" ]; then
PR_HEAD="$BRANCH_NAME"
else
FORK_OWNER="$GH_REPOSITORY_OWNER"
PR_HEAD="${FORK_OWNER}:${BRANCH_NAME}"
fi
# Find the PR number for this branch in the upstream repo
PR_NUMBER=$(gh pr list --repo "$TARGET_REPO" --head "$PR_HEAD" --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
echo "Adding comment to PR #$PR_NUMBER..."
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."
else
echo "⚠️ WARNING: Could not find PR for branch $PR_HEAD"
fi