Skip to content

Commit

Permalink
Merge pull request eclipse-zenoh#327 from fuzzypixelz/fix/release-wor…
Browse files Browse the repository at this point in the history
…kflow

fix: Release workflow
  • Loading branch information
milyin authored Apr 11, 2024
2 parents 09dcabe + db7024f commit 2ab2248
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ jobs:
with:
repo: ${{ github.repository }}
live-run: ${{ inputs.live-run || false }}
version: ${{ inputs.version }}
# NOTE(fuzzypixelz): When the version is undefined (e.g. on schedule
# events) we cannot use git-describe as CMake doesn't support it.
# However, we still need some placeholder version to test that the
# version can be reliably bumped.
version: ${{ inputs.version || '0.0.0' }}
github-token: ${{ secrets.BOT_TOKEN_WORKFLOW }}

- name: Checkout this repository
Expand All @@ -57,7 +61,7 @@ jobs:
env:
VERSION: ${{ steps.create-release-branch.outputs.version }}
BUMP_DEPS_VERSION: ${{ inputs.zenoh-version }}
BUMP_DEPS_PATTERN: ${{ inputs.zenoh-version && 'zenoh.*' || '^$' }}
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: [email protected]
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,9 @@ dkms.conf
.cache

# Platform dependent generated files
include/zenoh_configure.h
include/zenoh_configure.h

# CMake
CMakeFiles/
debug/
release/
40 changes: 21 additions & 19 deletions ci/scripts/bump-and-tag.bash
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env bash

set -eo pipefail
set -xeo pipefail

# Release number
readonly version=${VERSION:-''}
# Dependencies' pattern
readonly bump_deps_pattern=${BUMP_DEPS_PATTERN:-input BUMP_DEPS_PATTERN is required}
readonly bump_deps_pattern=${BUMP_DEPS_PATTERN:-''}
# Dependencies' version
readonly bump_deps_version=${BUMP_DEPS_VERSION:-''}
# Dependencies' git branch
Expand Down Expand Up @@ -46,25 +46,27 @@ toml_set_in_place Cargo.toml.in "package.metadata.deb.variants.libzenohc-dev.dep
git commit version.txt Cargo.toml Cargo.toml.in Cargo.lock -m "chore: Bump version to $version"

# Select all package dependencies that match $bump_deps_pattern and bump them to $bump_deps_version
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"
toml_set_in_place Cargo.toml.in "dependencies.$dep.version" "$bump_deps_version"
fi
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"
toml_set_in_place Cargo.toml.in "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"
toml_set_in_place Cargo.toml.in "dependencies.$dep.branch" "$bump_deps_branch"
fi
done
# Update lockfile
cargo check
if [[ -n $bump_deps_branch ]]; then
toml_set_in_place Cargo.toml "dependencies.$dep.branch" "$bump_deps_branch"
toml_set_in_place Cargo.toml.in "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.toml.in Cargo.lock -m "chore: Bump $bump_deps_pattern version to $bump_deps_version"
else
echo "info: no changes have been made to any dependencies"
if [[ -n $bump_deps_version || -n $bump_deps_branch ]]; then
git commit Cargo.toml Cargo.toml.in 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 "$version" -m "v$version"
Expand Down

0 comments on commit 2ab2248

Please sign in to comment.