Skip to content

Commit

Permalink
fix: Bump version in pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzypixelz committed Apr 17, 2024
1 parent ef5df8e commit 7823c22
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 10 deletions.
39 changes: 29 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,35 @@ on:

jobs:
tag:
name: Bump and tag crates
uses: eclipse-zenoh/ci/.github/workflows/branch-bump-tag-crates.yml@main
with:
repo: ${{ github.repository }}
live-run: ${{ inputs.live-run || false }}
version: ${{ inputs.version }}
bump-deps-version: ${{ inputs.zenoh-version }}
bump-deps-pattern: ${{ inputs.zenoh-version && 'zenoh.*' || '^$' }}
bump-deps-branch: ${{ inputs.zenoh-version && format('release/{0}', inputs.zenoh-version) || '' }}
secrets: inherit
name: Branch, Bump & tag
runs-on: ubuntu-latest
outputs:
version: ${{ steps.create-release-branch.outputs.version }}
branch: ${{ steps.create-release-branch.outputs.branch }}
steps:
- id: create-release-branch
uses: eclipse-zenoh/ci/create-release-branch@main
with:
repo: ${{ github.repository }}
live-run: ${{ inputs.live-run || false }}
version: ${{ inputs.version }}
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}

- name: Checkout this repository
uses: actions/checkout@v4
with:
ref: ${{ steps.create-release-branch.outputs.branch }}
token: ${{ secrets.BOT_TOKEN_WORKFLOW }}

- name: Bump and tag project
run: bash ci/scripts/bump-and-tag.bash
env:
VERSION: ${{ steps.create-release-branch.outputs.version }}
BUMP_DEPS_VERSION: ${{ inputs.zenoh-version }}
BUMP_DEPS_PATTERN: ${{ inputs.zenoh-version && 'zenoh.*' || '' }}
BUMP_DEPS_BRANCH: ${{ inputs.zenoh-version && format('release/{0}', inputs.zenoh-version) || '' }}
GIT_USER_NAME: eclipse-zenoh-bot
GIT_USER_EMAIL: eclipse-zenoh-bot@users.noreply.github.com

build-macos:
needs: tag
Expand Down
66 changes: 66 additions & 0 deletions ci/scripts/bump-and-tag.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

set -xeo pipefail

# Release number
readonly version=${VERSION:?input VERSION is required}
# Dependencies' pattern
readonly bump_deps_pattern=${BUMP_DEPS_PATTERN:-''}
# Dependencies' version
readonly bump_deps_version=${BUMP_DEPS_VERSION:-''}
# Dependencies' git branch
readonly bump_deps_branch=${BUMP_DEPS_BRANCH:-''}
# Git actor name
readonly git_user_name=${GIT_USER_NAME:?input GIT_USER_NAME is required}
# Git actor email
readonly git_user_email=${GIT_USER_EMAIL:?input GIT_USER_EMAIL is required}

cargo +stable install toml-cli

# NOTE(fuzzypixelz): toml-cli doesn't yet support in-place modification
# See: https://github.com/gnprice/toml-cli?tab=readme-ov-file#writing-ish-toml-set
function toml_set_in_place() {
local tmp=$(mktemp)
toml set "$1" "$2" "$3" > "$tmp"
mv "$tmp" "$1"
}

export GIT_AUTHOR_NAME=$git_user_name
export GIT_AUTHOR_EMAIL=$git_user_email
export GIT_COMMITTER_NAME=$git_user_name
export GIT_COMMITTER_EMAIL=$git_user_email

# Bump Cargo version
toml_set_in_place Cargo.toml "package.version" "$version"
# Propagate version change to pyproject.toml
toml_set_in_place pyproject.toml "project.version" "$version"

git commit version.txt Cargo.toml pyproject.toml -m "chore: Bump version to $version"

# Select all package dependencies that match $bump_deps_pattern and bump them to $bump_deps_version
if [[ "$bump_deps_pattern" != '' ]]; then
deps=$(toml get Cargo.toml dependencies | jq -r "keys.[] | select(test(\"$bump_deps_pattern\"))")
for dep in $deps; do
if [[ -n $bump_deps_version ]]; then
toml_set_in_place Cargo.toml "dependencies.$dep.version" "$bump_deps_version"
fi

if [[ -n $bump_deps_branch ]]; then
toml_set_in_place Cargo.toml "dependencies.$dep.branch" "$bump_deps_branch"
fi
done
# Update lockfile
cargo check

if [[ -n $bump_deps_version || -n $bump_deps_branch ]]; then
git commit Cargo.toml Cargo.lock -m "chore: Bump $bump_deps_pattern version to $bump_deps_version"
else
echo "warn: no changes have been made to any dependencies matching $bump_deps_pattern"
fi
fi

git tag --force "$version" -m "v$version"
git log -10
git show-ref --tags
git push origin
git push --force origin "$version"

0 comments on commit 7823c22

Please sign in to comment.