name: Bump crate versions on: workflow_dispatch: inputs: version: description: "Version to set (e.g. 1.21.0)" required: true type: string env: CI_BOT_AUTHOR: "Nym bot" CI_BOT_EMAIL: "nym-bot@users.noreply.github.com" jobs: version-bump: runs-on: arc-linux-latest env: RUSTUP_PERMIT_COPY_RENAME: 1 permissions: contents: write pull-requests: write steps: - name: Checkout repo uses: actions/checkout@v6 - name: Configure git identity run: | git config --global user.name "${{ env.CI_BOT_AUTHOR }}" git config --global user.email "${{ env.CI_BOT_EMAIL }}" - name: Install rust toolchain uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable override: true - name: Install cargo-workspaces run: cargo install cargo-workspaces - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: "20" - name: Validate version format run: | if ! npx semver "${{ inputs.version }}"; then echo "Error: '${{ inputs.version }}' is not valid semver" exit 1 fi - name: Get current version id: current_version run: | VERSION=$(grep -oP '^\s*version\s*=\s*"\K[0-9]+\.[0-9]+\.[0-9]+' Cargo.toml | head -1) echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Update workspace dependencies run: | # Match any semver version on lines with `path = `, not just the current workspace version. # This catches entries whose version has drifted (e.g. nym-sqlx-pool-guard at 1.2.0). sed -i '/path = /s/version = "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"/version = "${{ inputs.version }}"/g' Cargo.toml - name: Bump versions run: | cargo workspaces version custom ${{ inputs.version }} \ --no-git-commit \ --yes - name: Commit and push version bump run: | set -euo pipefail BASE_BRANCH="${GITHUB_REF_NAME}" PR_BRANCH="ci/crates-version-bump-${{ inputs.version }}-${GITHUB_RUN_ID}" git checkout -b "$PR_BRANCH" git add -A git commit -m "crates release: bump version to ${{ inputs.version }}" git push -u origin "$PR_BRANCH" cat > /tmp/crates-version-bump-pr-body.md <<'EOF' This PR was created by CI because direct pushes to the release branch are blocked by branch protection rules. ## Summary - Bump workspace crate versions to the requested release version. - Update workspace dependency versions accordingly. ## Notes - Merge this PR to proceed with crates.io publishing. EOF gh pr create \ --base "$BASE_BRANCH" \ --head "$PR_BRANCH" \ --title "crates release: bump version to ${{ inputs.version }}" \ --body-file /tmp/crates-version-bump-pr-body.md env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Show package versions run: cargo workspaces list --long