mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-07 13:30:31 +00:00
Extract install-action-manifest-schema and publish to crates-io (#657)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> Co-authored-by: Taiki Endo <te316e89@gmail.com>
This commit is contained in:
28
tools/ci/checkout-manifest-schema-branch.sh
Executable file
28
tools/ci/checkout-manifest-schema-branch.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
set -CeEuo pipefail
|
||||
IFS=$'\n\t'
|
||||
trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit with ${s}"; exit ${s}' ERR
|
||||
cd -- "$(dirname -- "$0")"
|
||||
|
||||
version="$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "install-action-manifest-schema") | .version')"
|
||||
if [[ "${version}" == "0."* ]]; then
|
||||
schema_version="0.$(cut -d. -f2 <<<"${version}")"
|
||||
else
|
||||
schema_version="$(cut -d. -f1 <<<"${version}")"
|
||||
fi
|
||||
branch="manifest-schema-${schema_version}"
|
||||
|
||||
git worktree add --force "${1?}"
|
||||
cd -- "$1"
|
||||
|
||||
if git fetch origin "${branch}"; then
|
||||
git checkout "origin/${branch}" -B "${branch}"
|
||||
elif ! git checkout "${branch}"; then
|
||||
# New branch with no history. Credit: https://stackoverflow.com/a/13969482
|
||||
git checkout --orphan "${branch}"
|
||||
git rm -rf . || true
|
||||
git config --local user.name github-actions
|
||||
git config --local user.email github-actions@github.com
|
||||
git commit -m 'Initial commit' --allow-empty
|
||||
fi
|
||||
Reference in New Issue
Block a user