From c7f94b58b5eb8e29f68733a5907dbc45c78e9083 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Mon, 7 Oct 2024 15:35:22 -0700 Subject: [PATCH] [ci] Factor out "release crate versions" script (#1824) 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. --- .github/workflows/release-crate-version.yml | 6 +----- ci/release_crate_version.sh | 21 +++++++++++++++++++++ githooks/pre-push | 4 +++- 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100755 ci/release_crate_version.sh diff --git a/.github/workflows/release-crate-version.yml b/.github/workflows/release-crate-version.yml index 034764d899..faa69e483d 100644 --- a/.github/workflows/release-crate-version.yml +++ b/.github/workflows/release-crate-version.yml @@ -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 diff --git a/ci/release_crate_version.sh b/ci/release_crate_version.sh new file mode 100755 index 0000000000..e916bdf45e --- /dev/null +++ b/ci/release_crate_version.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Copyright 2024 The Fuchsia Authors +# +# Licensed under a BSD-style license , Apache License, Version 2.0 +# , or the MIT +# license , 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 " >&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 diff --git a/githooks/pre-push b/githooks/pre-push index 2008373afd..4875f63bea 100755 --- a/githooks/pre-push +++ b/githooks/pre-push @@ -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 \ No newline at end of file +done +unset GLOBIGNORE