mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-22 15:30:31 +00:00
ci: Fix release workflow
This commit is contained in:
152
.github/workflows/release.yml
vendored
152
.github/workflows/release.yml
vendored
@@ -39,6 +39,7 @@ jobs:
|
|||||||
fallback: none
|
fallback: none
|
||||||
- id: check
|
- id: check
|
||||||
run: |
|
run: |
|
||||||
|
set +x
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit with ${s}"; exit ${s}' ERR
|
trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit with ${s}"; exit ${s}' ERR
|
||||||
retry() {
|
retry() {
|
||||||
@@ -222,6 +223,7 @@ jobs:
|
|||||||
- name: Create and push release commit and tag
|
- name: Create and push release commit and tag
|
||||||
id: push
|
id: push
|
||||||
run: |
|
run: |
|
||||||
|
set +x
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit with ${s}"; exit ${s}' ERR
|
trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit with ${s}"; exit ${s}' ERR
|
||||||
retry() {
|
retry() {
|
||||||
@@ -329,90 +331,84 @@ jobs:
|
|||||||
git tag -f "${major_version_tag}"
|
git tag -f "${major_version_tag}"
|
||||||
refs=("refs/heads/releases/${major_version_tag}" "+refs/tags/${major_version_tag}")
|
refs=("refs/heads/releases/${major_version_tag}" "+refs/tags/${major_version_tag}")
|
||||||
|
|
||||||
if [[ "${INSTALL_ACTION}" == 'true' ]]; then
|
tools=()
|
||||||
tools=()
|
for tool in tools/codegen/base/*.json; do
|
||||||
for tool in tools/codegen/base/*.json; do
|
tool="${tool##*/}"
|
||||||
tool="${tool##*/}"
|
tools+=("${tool%.*}")
|
||||||
tools+=("${tool%.*}")
|
done
|
||||||
done
|
# Aliases.
|
||||||
# Aliases.
|
# NB: Update case for aliases in main.sh, tool input option in test-alias job
|
||||||
# NB: Update case for aliases in main.sh, tool input option in test-alias job
|
# in .github/workflows/ci.yml, and match for alias for tools/codegen/src/tools-markdown.rs.
|
||||||
# in .github/workflows/ci.yml, and match for alias for tools/codegen/src/tools-markdown.rs.
|
tools+=(
|
||||||
tools+=(
|
nextest
|
||||||
nextest
|
taplo-cli
|
||||||
taplo-cli
|
typos-cli
|
||||||
typos-cli
|
wasm-bindgen-cli
|
||||||
wasm-bindgen-cli
|
wasmtime-cli
|
||||||
wasmtime-cli
|
)
|
||||||
)
|
# Non-manifest-based tools.
|
||||||
# Non-manifest-based tools.
|
tools+=(valgrind)
|
||||||
tools+=(valgrind)
|
|
||||||
|
|
||||||
branches=()
|
branches=()
|
||||||
for tool in "${tools[@]}"; do
|
for tool in "${tools[@]}"; do
|
||||||
git checkout -b "releases/${tool}"
|
git checkout -b "releases/${tool}"
|
||||||
sed -E "${in_place[@]}" action.yml \
|
sed -E "${in_place[@]}" action.yml \
|
||||||
-e "s/required: true/required: false/g" \
|
-e "s/required: true/required: false/g" \
|
||||||
-e "s/# default: #publish:tool/default: ${tool}/g"
|
-e "s/# default: #publish:tool/default: ${tool}/g"
|
||||||
git add action.yml
|
git add action.yml
|
||||||
git commit -m "${tool}"
|
git commit -m "${tool}"
|
||||||
git tag -f "${tool}"
|
git tag -f "${tool}"
|
||||||
git checkout main
|
git checkout main
|
||||||
refs+=("+refs/heads/releases/${tool}" "+refs/tags/${tool}")
|
refs+=("+refs/heads/releases/${tool}" "+refs/tags/${tool}")
|
||||||
branches+=("releases/${tool}")
|
branches+=("releases/${tool}")
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
retry git push origin --atomic "${refs[@]}"
|
retry git push origin --atomic "${refs[@]}"
|
||||||
git branch -d "releases/${major_version_tag}"
|
git branch -d "releases/${major_version_tag}"
|
||||||
|
git branch -D "${branches[@]}"
|
||||||
|
|
||||||
if [[ "${INSTALL_ACTION}" == 'true' ]]; then
|
schema_workspace=/tmp/workspace
|
||||||
git branch -D "${branches[@]}"
|
rm -rf -- "${schema_workspace}"
|
||||||
|
# Checkout manifest-schema branch
|
||||||
schema_workspace=/tmp/workspace
|
schema_version="$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "install-action-manifest-schema") | .version')"
|
||||||
rm -rf -- "${schema_workspace}"
|
if [[ "${schema_version}" == "0."* ]]; then
|
||||||
# Checkout manifest-schema branch
|
schema_version="0.$(cut -d. -f2 <<<"${schema_version}")"
|
||||||
schema_version="$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "install-action-manifest-schema") | .version')"
|
else
|
||||||
if [[ "${schema_version}" == "0."* ]]; then
|
schema_version="$(cut -d. -f1 <<<"${schema_version}")"
|
||||||
schema_version="0.$(cut -d. -f2 <<<"${schema_version}")"
|
|
||||||
else
|
|
||||||
schema_version="$(cut -d. -f1 <<<"${schema_version}")"
|
|
||||||
fi
|
|
||||||
schema_branch="manifest-schema-${schema_version}"
|
|
||||||
|
|
||||||
git worktree add --force "${schema_workspace}"
|
|
||||||
(
|
|
||||||
cd -- "${schema_workspace}"
|
|
||||||
if git fetch origin "${schema_branch}"; then
|
|
||||||
git checkout "origin/${schema_branch}" -B "${schema_branch}"
|
|
||||||
elif ! git checkout "${schema_branch}"; then
|
|
||||||
# New branch with no history. Credit: https://stackoverflow.com/a/13969482
|
|
||||||
git checkout --orphan "${schema_branch}"
|
|
||||||
git rm -rf -- . || true
|
|
||||||
git commit -m 'Initial commit' --allow-empty
|
|
||||||
fi
|
|
||||||
)
|
|
||||||
|
|
||||||
# Copy over schema
|
|
||||||
cp -- ./manifests/* "${schema_workspace}"
|
|
||||||
|
|
||||||
(
|
|
||||||
cd -- "${schema_workspace}"
|
|
||||||
# Stage changes
|
|
||||||
git add .
|
|
||||||
# Detect changes, then commit and push if changes exist
|
|
||||||
if [[ "$(git status --porcelain=v1 | LC_ALL=C wc -l)" != "0" ]]; then
|
|
||||||
git commit -m 'Update manifest schema'
|
|
||||||
retry git push origin HEAD
|
|
||||||
fi
|
|
||||||
)
|
|
||||||
|
|
||||||
rm -rf -- "${schema_workspace}"
|
|
||||||
git worktree prune
|
|
||||||
# TODO: get branch in schema_workspace dir instead
|
|
||||||
git branch -D "${schema_branch}" "${schema_workspace##*/}"
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
schema_branch="manifest-schema-${schema_version}"
|
||||||
|
|
||||||
|
git worktree add --force "${schema_workspace}"
|
||||||
|
(
|
||||||
|
cd -- "${schema_workspace}"
|
||||||
|
if git fetch origin "${schema_branch}"; then
|
||||||
|
git checkout "origin/${schema_branch}" -B "${schema_branch}"
|
||||||
|
elif ! git checkout "${schema_branch}"; then
|
||||||
|
# New branch with no history. Credit: https://stackoverflow.com/a/13969482
|
||||||
|
git checkout --orphan "${schema_branch}"
|
||||||
|
git rm -rf -- . || true
|
||||||
|
git commit -m 'Initial commit' --allow-empty
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
|
||||||
|
# Copy over schema
|
||||||
|
cp -- ./manifests/* "${schema_workspace}"
|
||||||
|
|
||||||
|
(
|
||||||
|
cd -- "${schema_workspace}"
|
||||||
|
# Stage changes
|
||||||
|
git add .
|
||||||
|
# Detect changes, then commit and push if changes exist
|
||||||
|
if [[ "$(git status --porcelain=v1 | LC_ALL=C wc -l)" != "0" ]]; then
|
||||||
|
git commit -m 'Update manifest schema'
|
||||||
|
retry git push origin HEAD
|
||||||
|
fi
|
||||||
|
)
|
||||||
|
|
||||||
|
rm -rf -- "${schema_workspace}"
|
||||||
|
git worktree prune
|
||||||
|
# TODO: get branch in schema_workspace dir instead
|
||||||
|
git branch -D "${schema_branch}" "${schema_workspace##*/}"
|
||||||
)
|
)
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ needs.prepare.outputs.version }}
|
VERSION: ${{ needs.prepare.outputs.version }}
|
||||||
|
|||||||
Reference in New Issue
Block a user