Skip to content

Commit

Permalink
[ci] Factor out "release crate versions" script (#1824)
Browse files Browse the repository at this point in the history
Sometimes we want to manually release, often when we are making a change
and releasing it in the same commit. This makes that process easier.
  • Loading branch information
joshlf authored Oct 7, 2024
1 parent 0475310 commit c7f94b5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/release-crate-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ jobs:
ref: ${{ github.event.inputs.branch }}
persist-credentials: false
- name: Overwrite Cargo.toml files
run: |
set -e
sed -i -e 's/^zerocopy-derive = { version = "=[0-9a-zA-Z\.-]*"/zerocopy-derive = { version = "=${{ github.event.inputs.version }}"/' Cargo.toml
sed -i -e 's/^version = "[0-9a-zA-Z\.-]*"/version = "${{ github.event.inputs.version }}"/' Cargo.toml zerocopy-derive/Cargo.toml
run: ./ci/release_crate_version.sh ${{ github.event.inputs.version }}

- name: Submit PR
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
Expand Down
21 changes: 21 additions & 0 deletions ci/release_crate_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
#
# Copyright 2024 The Fuchsia Authors
#
# Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0
# <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT
# license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option.
# This file may not be copied, modified, or distributed except according to
# those terms.

set -e

if [ $# -ne 1 ]; then
echo "Usage: $0 <version>" >&2
exit 1
fi

VERSION="$1"

sed -i -e "s/^zerocopy-derive = { version = \"=[0-9a-zA-Z\.-]*\"/zerocopy-derive = { version = \"=$VERSION\"/" Cargo.toml
sed -i -e "s/^version = \"[0-9a-zA-Z\.-]*\"/version = \"$VERSION\"/" Cargo.toml zerocopy-derive/Cargo.toml
4 changes: 3 additions & 1 deletion githooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ wait $VERSIONS_PID
#
# This was added because, in #728, we added `ci/check_all_toolchains_tested.sh`
# without calling it from this script.
GLOBIGNORE="./*/release_crate_version.sh" # We don't want to run this one
for f in ./ci/*; do
grep "$f" githooks/pre-push >/dev/null || { echo "$f not called from githooks/pre-push" >&2 ; exit 1; }
done
done
unset GLOBIGNORE

0 comments on commit c7f94b5

Please sign in to comment.