mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-21 15:10:27 +00:00
tools: Update scripts and markdownlint config
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
# https://github.com/DavidAnson/markdownlint#rules--aliases
|
# https://github.com/DavidAnson/markdownlint/blob/HEAD/doc/Rules.md
|
||||||
config:
|
config:
|
||||||
line-length: false
|
line-length: false # MD013
|
||||||
no-duplicate-heading: false
|
no-duplicate-heading: false # MD024
|
||||||
no-inline-html: false
|
no-blanks-blockquote: false # MD028
|
||||||
no-emphasis-as-heading: false
|
no-inline-html: false # MD033
|
||||||
|
no-emphasis-as-heading: false # MD036
|
||||||
|
|
||||||
# https://github.com/DavidAnson/markdownlint-cli2#markdownlint-cli2jsonc
|
# https://github.com/DavidAnson/markdownlint-cli2#markdownlint-cli2jsonc
|
||||||
noBanner: true
|
noBanner: true
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||||
set -eEuo pipefail
|
set -CeEuo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
cd "$(dirname "$0")"/..
|
trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit with ${s}"; exit ${s}' ERR
|
||||||
|
cd -- "$(dirname -- "$0")"/..
|
||||||
|
|
||||||
# Update manifests
|
# Update manifests
|
||||||
#
|
#
|
||||||
@@ -15,6 +16,7 @@ if [[ $# -gt 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for manifest in tools/codegen/base/*.json; do
|
for manifest in tools/codegen/base/*.json; do
|
||||||
package=$(basename "${manifest%.*}")
|
package="${manifest##*/}"
|
||||||
|
package="${package%.*}"
|
||||||
cargo run --manifest-path tools/codegen/Cargo.toml --release -- "${package}" latest
|
cargo run --manifest-path tools/codegen/Cargo.toml --release -- "${package}" latest
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||||
set -eEuo pipefail
|
set -CeEuo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
cd "$(dirname "$0")"/..
|
trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit with ${s}"; exit ${s}' ERR
|
||||||
|
cd -- "$(dirname -- "$0")"/..
|
||||||
# shellcheck disable=SC2154
|
|
||||||
trap 's=$?; echo >&2 "$0: error on line "${LINENO}": ${BASH_COMMAND}"; exit ${s}' ERR
|
|
||||||
|
|
||||||
# Publish a new release.
|
# Publish a new release.
|
||||||
#
|
#
|
||||||
@@ -26,7 +24,7 @@ retry() {
|
|||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
bail() {
|
bail() {
|
||||||
echo >&2 "error: $*"
|
printf >&2 'error: %s\n' "$*"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +39,11 @@ fi
|
|||||||
if [[ $# -gt 1 ]]; then
|
if [[ $# -gt 1 ]]; then
|
||||||
bail "invalid argument '$2'"
|
bail "invalid argument '$2'"
|
||||||
fi
|
fi
|
||||||
|
if { sed --help 2>&1 || true; } | grep -Eq -e '-i extension'; then
|
||||||
|
in_place=(-i '')
|
||||||
|
else
|
||||||
|
in_place=(-i)
|
||||||
|
fi
|
||||||
|
|
||||||
# Make sure there is no uncommitted change.
|
# Make sure there is no uncommitted change.
|
||||||
git diff --exit-code
|
git diff --exit-code
|
||||||
@@ -52,12 +55,15 @@ if gh release view "${tag}" &>/dev/null; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure that the release was created from an allowed branch.
|
# Make sure that the release was created from an allowed branch.
|
||||||
if ! git branch | grep -q '\* main$'; then
|
if ! git branch | grep -Eq '\* main$'; then
|
||||||
bail "current branch is not 'main'"
|
bail "current branch is not 'main'"
|
||||||
fi
|
fi
|
||||||
|
if ! git remote -v | grep -F origin | grep -Eq 'github\.com[:/]taiki-e/'; then
|
||||||
|
bail "cannot publish a new release from fork repository"
|
||||||
|
fi
|
||||||
|
|
||||||
release_date=$(date -u '+%Y-%m-%d')
|
release_date=$(date -u '+%Y-%m-%d')
|
||||||
tags=$(git --no-pager tag | (grep -E "^${tag_prefix}[0-9]+" || true))
|
tags=$(git --no-pager tag | { grep -E "^${tag_prefix}[0-9]+" || true; })
|
||||||
if [[ -n "${tags}" ]]; then
|
if [[ -n "${tags}" ]]; then
|
||||||
# Make sure the same release does not exist in changelog.
|
# Make sure the same release does not exist in changelog.
|
||||||
if grep -Eq "^## \\[${version//./\\.}\\]" "${changelog}"; then
|
if grep -Eq "^## \\[${version//./\\.}\\]" "${changelog}"; then
|
||||||
@@ -67,11 +73,12 @@ if [[ -n "${tags}" ]]; then
|
|||||||
bail "link to ${version} already exist in ${changelog}"
|
bail "link to ${version} already exist in ${changelog}"
|
||||||
fi
|
fi
|
||||||
# Update changelog.
|
# Update changelog.
|
||||||
remote_url=$(grep -E '^\[Unreleased\]: https://' "${changelog}" | sed 's/^\[Unreleased\]: //; s/\.\.\.HEAD$//')
|
remote_url=$(grep -E '^\[Unreleased\]: https://' "${changelog}" | sed -E 's/^\[Unreleased\]: //; s/\.\.\.HEAD$//')
|
||||||
prev_tag="${remote_url#*/compare/}"
|
prev_tag="${remote_url#*/compare/}"
|
||||||
remote_url="${remote_url%/compare/*}"
|
remote_url="${remote_url%/compare/*}"
|
||||||
sed -i "s/^## \\[Unreleased\\]/## [Unreleased]\\n\\n## [${version}] - ${release_date}/" "${changelog}"
|
sed -E "${in_place[@]}" \
|
||||||
sed -i "s#^\[Unreleased\]: https://.*#[Unreleased]: ${remote_url}/compare/${tag}...HEAD\\n[${version}]: ${remote_url}/compare/${prev_tag}...${tag}#" "${changelog}"
|
-e "s/^## \\[Unreleased\\]/## [Unreleased]\\n\\n## [${version}] - ${release_date}/" \
|
||||||
|
-e "s#^\[Unreleased\]: https://.*#[Unreleased]: ${remote_url}/compare/${tag}...HEAD\\n[${version}]: ${remote_url}/compare/${prev_tag}...${tag}#" "${changelog}"
|
||||||
if ! grep -Eq "^## \\[${version//./\\.}\\] - ${release_date}$" "${changelog}"; then
|
if ! grep -Eq "^## \\[${version//./\\.}\\] - ${release_date}$" "${changelog}"; then
|
||||||
bail "failed to update ${changelog}"
|
bail "failed to update ${changelog}"
|
||||||
fi
|
fi
|
||||||
@@ -94,18 +101,9 @@ changes=$(parse-changelog "${changelog}" "${version}")
|
|||||||
if [[ -z "${changes}" ]]; then
|
if [[ -z "${changes}" ]]; then
|
||||||
bail "changelog for ${version} has no body"
|
bail "changelog for ${version} has no body"
|
||||||
fi
|
fi
|
||||||
echo "============== CHANGELOG =============="
|
printf '============== CHANGELOG ==============\n'
|
||||||
echo "${changes}"
|
printf '%s\n' "${changes}"
|
||||||
echo "======================================="
|
printf '=======================================\n'
|
||||||
|
|
||||||
tools=()
|
|
||||||
for tool in tools/codegen/base/*.json; do
|
|
||||||
tools+=("$(basename "${tool%.*}")")
|
|
||||||
done
|
|
||||||
# Alias
|
|
||||||
tools+=(nextest)
|
|
||||||
# Not manifest-based
|
|
||||||
tools+=(valgrind)
|
|
||||||
|
|
||||||
if [[ -n "${tags}" ]]; then
|
if [[ -n "${tags}" ]]; then
|
||||||
# Create a release commit.
|
# Create a release commit.
|
||||||
@@ -134,10 +132,20 @@ retry git push origin --tags
|
|||||||
git checkout main
|
git checkout main
|
||||||
git branch -d "${major_version_tag}"
|
git branch -d "${major_version_tag}"
|
||||||
|
|
||||||
|
tools=()
|
||||||
|
for tool in tools/codegen/base/*.json; do
|
||||||
|
tool="${tool##*/}"
|
||||||
|
tools+=("${tool%.*}")
|
||||||
|
done
|
||||||
|
# Alias
|
||||||
|
tools+=(nextest)
|
||||||
|
# Not manifest-based
|
||||||
|
tools+=(valgrind)
|
||||||
|
|
||||||
for tool in "${tools[@]}"; do
|
for tool in "${tools[@]}"; do
|
||||||
git checkout -b "${tool}"
|
git checkout -b "${tool}"
|
||||||
sed -i -e "s/required: true/required: false/g" action.yml
|
sed -E "${in_place[@]}" "s/required: true/required: false/g" action.yml
|
||||||
sed -i -e "s/# default: #publish:tool/default: ${tool}/g" action.yml
|
sed -E "${in_place[@]}" "s/# default: #publish:tool/default: ${tool}/g" action.yml
|
||||||
git add action.yml
|
git add action.yml
|
||||||
git commit -m "${tool}"
|
git commit -m "${tool}"
|
||||||
retry git push origin -f refs/heads/"${tool}"
|
retry git push origin -f refs/heads/"${tool}"
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ if [[ -n "$(git ls-files '*.rs')" ]]; then
|
|||||||
binaries=''
|
binaries=''
|
||||||
metadata=$(cargo metadata --format-version=1 --no-deps)
|
metadata=$(cargo metadata --format-version=1 --no-deps)
|
||||||
has_public_crate=''
|
has_public_crate=''
|
||||||
|
has_root_crate=''
|
||||||
venv_install_yq
|
venv_install_yq
|
||||||
for id in $(jq <<<"${metadata}" '.workspace_members[]'); do
|
for id in $(jq <<<"${metadata}" '.workspace_members[]'); do
|
||||||
pkg=$(jq <<<"${metadata}" ".packages[] | select(.id == ${id})")
|
pkg=$(jq <<<"${metadata}" ".packages[] | select(.id == ${id})")
|
||||||
@@ -178,6 +179,7 @@ if [[ -n "$(git ls-files '*.rs')" ]]; then
|
|||||||
publish=$(jq <<<"${root_pkg}" -r '.publish')
|
publish=$(jq <<<"${root_pkg}" -r '.publish')
|
||||||
# Publishing is unrestricted if null, and forbidden if an empty array.
|
# Publishing is unrestricted if null, and forbidden if an empty array.
|
||||||
if [[ "${publish}" != "[]" ]]; then
|
if [[ "${publish}" != "[]" ]]; then
|
||||||
|
has_root_crate=1
|
||||||
exclude=$(venv tomlq -r '.package.exclude[]' Cargo.toml)
|
exclude=$(venv tomlq -r '.package.exclude[]' Cargo.toml)
|
||||||
if ! grep <<<"${exclude}" -Eq '^/\.\*$'; then
|
if ! grep <<<"${exclude}" -Eq '^/\.\*$'; then
|
||||||
error "top-level Cargo.toml of non-virtual workspace should have 'exclude' field with \"/.*\""
|
error "top-level Cargo.toml of non-virtual workspace should have 'exclude' field with \"/.*\""
|
||||||
@@ -200,6 +202,13 @@ if [[ -n "$(git ls-files '*.rs')" ]]; then
|
|||||||
# TODO: fully respect exclude field in Cargo.toml.
|
# TODO: fully respect exclude field in Cargo.toml.
|
||||||
case "${p}" in
|
case "${p}" in
|
||||||
.* | tools/* | target-specs/*) continue ;;
|
.* | tools/* | target-specs/*) continue ;;
|
||||||
|
*/*) ;;
|
||||||
|
*)
|
||||||
|
# If there is no crate at root, executables at the repository root directory if always okay.
|
||||||
|
if [[ -z "${has_root_crate}" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
if [[ -x "${p}" ]]; then
|
if [[ -x "${p}" ]]; then
|
||||||
executables+="${p}"$'\n'
|
executables+="${p}"$'\n'
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||||
set -eEuo pipefail
|
set -CeEuo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
cd "$(dirname "$0")"/..
|
trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit with ${s}"; exit ${s}' ERR
|
||||||
|
cd -- "$(dirname -- "$0")"/..
|
||||||
|
|
||||||
# Update markdown
|
# Update markdown
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user