Skip to content

Bump a dependency

Bump a dependency #106

Workflow file for this run

name: Bump a dependency
on:
workflow_dispatch:
inputs:
package:
required: true
type: string
description: package name such as `sentry-arroyo` (_ vs - does not matter)
version:
required: true
type: string
description: desired version such as `1.2.3`, or `latest` to pull the latest version from PyPI
# for use in other (cron/scheduled) workflows to bump specific
# company-internal dependencies on a more aggressive schedule
workflow_call:
inputs:
package:
required: true
type: string
version:
required: true
type: string
# disable all permissions -- we use the PAT's permissions instead
permissions: {}
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ secrets.GETSENTRY_BOT_REVERT_TOKEN }}
- uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6
with:
version: '0.8.2'
- run: |
set -euxo pipefail
if [ "$VERSION" = latest ]; then
VERSION="$(curl -sL https://pypi.org/pypi/$PACKAGE/json | jq -r .info.version)"
fi
git checkout -b "bot/bump-version/$PACKAGE/$VERSION"
python3 -S -m tools.bump_version "$PACKAGE" "$VERSION"
re="$(sed 's/[_-]/[_-]/g' <<< "$PACKAGE")"
# Update Cargo.toml dependencies (format: package = "version")
sed -i "s/^\($re\) = \"[^\"]*\"/\1 = \"$VERSION\"/g" -- rust_snuba/Cargo.toml
# Also handle dependencies with features (format: package = { version = "version", features = [...] })
sed -i "s/^\($re\) = { version = \"[^\"]*\"/\1 = { version = \"$VERSION\"/g" -- rust_snuba/Cargo.toml
# Update Cargo.lock if Cargo.toml was modified
if ! git diff --exit-code -- rust_snuba/Cargo.toml > /dev/null 2>&1; then
cd rust_snuba
# Try updating with underscores (cargo prefers underscores in package names)
CARGO_PACKAGE="$(echo "$PACKAGE" | sed 's/-/_/g')"
if ! cargo update --package "$CARGO_PACKAGE" 2>/dev/null; then
# If that fails, try with the original package name
cargo update --package "$PACKAGE"
fi
cd ..
fi
if git diff --exit-code; then
exit 0
fi
git \
-c user.name=getsentry-bot \
-c user.email='[email protected]' \
commit \
--all \
--message "ref: bump $PACKAGE to $VERSION" \
--message "Co-Authored-By: $SENDER <[email protected]>"
git push origin HEAD --quiet
gh pr create --fill
env:
# Using this instead of BUMP_SENTRY_TOKEN as per advice from asottile
GH_TOKEN: ${{ secrets.GETSENTRY_BOT_REVERT_TOKEN }}
PACKAGE: ${{ inputs.package }}
VERSION: ${{ inputs.version }}
SENDER: ${{ github.event.sender.login }}
SENDER_ID: ${{ github.event.sender.id }}