mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-01 03:00:26 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4abeafc99 | ||
|
|
0180de5ee1 | ||
|
|
008e9ca06e | ||
|
|
4d0d5ef7c9 | ||
|
|
56a03286db | ||
|
|
fc57aaa8ad | ||
|
|
996e798ea2 | ||
|
|
6132093ff5 |
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@@ -26,14 +26,14 @@ jobs:
|
||||
- ubuntu-18.04
|
||||
tool:
|
||||
- cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,shellcheck,shfmt
|
||||
- cargo-hack@0.5.9,cargo-llvm-cov@0.1.13,cargo-minimal-versions@0.1.0,parse-changelog@0.4.5,cross@0.2.1,shellcheck@0.8.0,shfmt@3.4.2
|
||||
- cargo-hack@0.5.10,cargo-llvm-cov@0.1.13,cargo-minimal-versions@0.1.1,parse-changelog@0.4.6,cross@0.2.1,shellcheck@0.8.0,shfmt@3.4.2
|
||||
include:
|
||||
- os: macos-10.15
|
||||
tool: cargo-hack@0.5.9,cargo-llvm-cov@0.1.13,cargo-minimal-versions@0.1.0,parse-changelog@0.4.5,cross@0.2.1,shellcheck@0.8.0,shfmt@3.4.2
|
||||
tool: cargo-hack@0.5.10,cargo-llvm-cov@0.1.13,cargo-minimal-versions@0.1.1,parse-changelog@0.4.6,cross@0.2.1,shellcheck@0.8.0,shfmt@3.4.2
|
||||
- os: windows-2019
|
||||
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog
|
||||
- os: windows-2019
|
||||
tool: cargo-hack@0.5.9,cargo-llvm-cov@0.1.13,cargo-minimal-versions@0.1.0,parse-changelog@0.4.5,cross@0.2.1
|
||||
tool: cargo-hack@0.5.10,cargo-llvm-cov@0.1.13,cargo-minimal-versions@0.1.1,parse-changelog@0.4.6,cross@0.2.1
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -49,9 +49,9 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: taiki-e/github-actions/install@main
|
||||
with:
|
||||
tool: prettier,shellcheck,shfmt
|
||||
- uses: taiki-e/install-action@shellcheck
|
||||
- uses: taiki-e/install-action@shfmt
|
||||
- run: npm install prettier
|
||||
- run: shfmt -d $(git ls-files '*.sh')
|
||||
if: always()
|
||||
- run: npx prettier -c $(git ls-files '*.yml')
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,7 +1,6 @@
|
||||
node_modules
|
||||
package-lock.json
|
||||
package.json
|
||||
tmp
|
||||
|
||||
# For platform and editor specific settings, it is recommended to add to
|
||||
# a global .gitignore file.
|
||||
|
||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -10,9 +10,19 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.0.2] - 2022-01-05
|
||||
|
||||
- Update `cargo-minimal-versions@latest` to 0.1.1.
|
||||
|
||||
## [1.0.1] - 2022-01-05
|
||||
|
||||
- Fix error in cases where the release has been created but the binary has not yet been uploaded.
|
||||
|
||||
## [1.0.0] - 2021-12-30
|
||||
|
||||
Initial release
|
||||
|
||||
[Unreleased]: https://github.com/taiki-e/install-action/compare/v1.0.0...HEAD
|
||||
[Unreleased]: https://github.com/taiki-e/install-action/compare/v1.0.2...HEAD
|
||||
[1.0.2]: https://github.com/taiki-e/install-action/compare/v1.0.1...v1.0.2
|
||||
[1.0.1]: https://github.com/taiki-e/install-action/compare/v1.0.0...v1.0.1
|
||||
[1.0.0]: https://github.com/taiki-e/install-action/releases/tag/v1.0.0
|
||||
|
||||
47
main.sh
47
main.sh
@@ -54,11 +54,18 @@ for tool in "${tools[@]}"; do
|
||||
tool="${tool%@*}"
|
||||
info "installing ${tool}@${version}"
|
||||
case "${tool}" in
|
||||
# https://github.com/taiki-e/cargo-hack/releases
|
||||
# https://github.com/taiki-e/cargo-llvm-cov/releases
|
||||
# https://github.com/taiki-e/cargo-minimal-versions/releases
|
||||
# https://github.com/taiki-e/parse-changelog/releases
|
||||
cargo-hack | cargo-llvm-cov | cargo-minimal-versions | parse-changelog)
|
||||
case "${tool}" in
|
||||
# https://github.com/taiki-e/cargo-hack/releases
|
||||
cargo-hack) latest_version="0.5.10" ;;
|
||||
# https://github.com/taiki-e/cargo-llvm-cov/releases
|
||||
cargo-llvm-cov) latest_version="0.1.13" ;;
|
||||
# https://github.com/taiki-e/cargo-minimal-versions/releases
|
||||
cargo-minimal-versions) latest_version="0.1.1" ;;
|
||||
# https://github.com/taiki-e/parse-changelog/releases
|
||||
parse-changelog) latest_version="0.4.6" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
repo="taiki-e/${tool}"
|
||||
case "${OSTYPE}" in
|
||||
linux*) target="x86_64-unknown-linux-musl" ;;
|
||||
@@ -67,14 +74,15 @@ for tool in "${tools[@]}"; do
|
||||
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
|
||||
esac
|
||||
case "${version}" in
|
||||
latest) url="https://github.com/${repo}/releases/latest/download/${tool}-${target}.tar.gz" ;;
|
||||
*) url="https://github.com/${repo}/releases/download/v${version}/${tool}-${target}.tar.gz" ;;
|
||||
latest) version="${latest_version}" ;;
|
||||
esac
|
||||
url="https://github.com/${repo}/releases/download/v${version}/${tool}-${target}.tar.gz"
|
||||
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" \
|
||||
| tar xzf - -C ~/.cargo/bin
|
||||
;;
|
||||
# https://github.com/rust-embedded/cross/releases
|
||||
cross)
|
||||
# https://github.com/rust-embedded/cross/releases
|
||||
latest_version="0.2.1"
|
||||
repo="rust-embedded/cross"
|
||||
case "${OSTYPE}" in
|
||||
linux*) target="x86_64-unknown-linux-musl" ;;
|
||||
@@ -83,15 +91,15 @@ for tool in "${tools[@]}"; do
|
||||
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
|
||||
esac
|
||||
case "${version}" in
|
||||
latest) tag=$(retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused https://api.github.com/repos/${repo}/releases/latest | jq -r '.tag_name') ;;
|
||||
*) tag="v${version}" ;;
|
||||
latest) version="${latest_version}" ;;
|
||||
esac
|
||||
url="https://github.com/${repo}/releases/download/${tag}/cross-${tag}-${target}.tar.gz"
|
||||
url="https://github.com/${repo}/releases/download/v${version}/cross-v${version}-${target}.tar.gz"
|
||||
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" \
|
||||
| tar xzf - -C ~/.cargo/bin
|
||||
;;
|
||||
# https://github.com/koalaman/shellcheck/releases
|
||||
shellcheck)
|
||||
# https://github.com/koalaman/shellcheck/releases
|
||||
latest_version="0.8.0"
|
||||
repo="koalaman/shellcheck"
|
||||
case "${OSTYPE}" in
|
||||
linux*)
|
||||
@@ -105,14 +113,15 @@ for tool in "${tools[@]}"; do
|
||||
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
|
||||
esac
|
||||
case "${version}" in
|
||||
latest) tag="$(retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused https://api.github.com/repos/${repo}/releases/latest | jq -r '.tag_name')" ;;
|
||||
*) tag="v${version}" ;;
|
||||
latest) version="${latest_version}" ;;
|
||||
esac
|
||||
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "https://github.com/${repo}/releases/download/${tag}/shellcheck-${tag}.${target}.x86_64.tar.xz" \
|
||||
| tar xJf - --strip-components 1 -C /usr/local/bin "shellcheck-${tag}/shellcheck"
|
||||
url="https://github.com/${repo}/releases/download/v${version}/shellcheck-v${version}.${target}.x86_64.tar.xz"
|
||||
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" \
|
||||
| tar xJf - --strip-components 1 -C /usr/local/bin "shellcheck-v${version}/shellcheck"
|
||||
;;
|
||||
# https://github.com/mvdan/sh/releases
|
||||
shfmt)
|
||||
# https://github.com/mvdan/sh/releases
|
||||
latest_version="3.4.2"
|
||||
repo="mvdan/sh"
|
||||
case "${OSTYPE}" in
|
||||
linux*) target="linux_amd64" ;;
|
||||
@@ -121,10 +130,10 @@ for tool in "${tools[@]}"; do
|
||||
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
|
||||
esac
|
||||
case "${version}" in
|
||||
latest) tag="$(retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused https://api.github.com/repos/${repo}/releases/latest | jq -r '.tag_name')" ;;
|
||||
*) tag="v${version}" ;;
|
||||
latest) version="${latest_version}" ;;
|
||||
esac
|
||||
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused -o /usr/local/bin/shfmt "https://github.com/${repo}/releases/download/${tag}/shfmt_${tag}_${target}"
|
||||
url="https://github.com/${repo}/releases/download/v${version}/shfmt_v${version}_${target}"
|
||||
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused -o /usr/local/bin/shfmt "${url}"
|
||||
chmod +x /usr/local/bin/shfmt
|
||||
;;
|
||||
*) bail "unsupported tool '${tool}'" ;;
|
||||
|
||||
@@ -16,12 +16,35 @@ bail() {
|
||||
echo >&2 "error: $*"
|
||||
exit 1
|
||||
}
|
||||
warn() {
|
||||
echo >&2 "warning: $*"
|
||||
}
|
||||
info() {
|
||||
echo >&2 "info: $*"
|
||||
}
|
||||
|
||||
version="${1:?}"
|
||||
version="${version#v}"
|
||||
tag="v${version}"
|
||||
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z\.-]+)?(\+[0-9A-Za-z\.-]+)?$ ]]; then
|
||||
bail "invalid version format '${version}'"
|
||||
fi
|
||||
if [[ $# -gt 1 ]]; then
|
||||
bail "invalid argument '$2'"
|
||||
fi
|
||||
|
||||
# Make sure there is no uncommitted change.
|
||||
git diff --exit-code
|
||||
git diff --exit-code --staged
|
||||
|
||||
# Make sure that a valid release note for this version exists.
|
||||
# https://github.com/taiki-e/parse-changelog
|
||||
echo "============== CHANGELOG =============="
|
||||
parse-changelog CHANGELOG.md "${version}"
|
||||
echo "======================================="
|
||||
|
||||
if ! grep <CHANGELOG.md -E "^\\[${version//./\\.}\\]: " >/dev/null; then
|
||||
bail "not found link to [${version}] in CHANGELOG.md"
|
||||
fi
|
||||
|
||||
# Make sure the same release has not been created in the past.
|
||||
if gh release view "${tag}" &>/dev/null; then
|
||||
bail "tag '${tag}' has already been created and pushed"
|
||||
fi
|
||||
|
||||
tools=(
|
||||
cargo-hack
|
||||
@@ -33,56 +56,16 @@ tools=(
|
||||
shfmt
|
||||
)
|
||||
|
||||
# Parse arguments.
|
||||
version="${1:?}"
|
||||
version="${version#v}"
|
||||
tag="v${version}"
|
||||
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z\.-]+)?(\+[0-9A-Za-z\.-]+)?$ ]]; then
|
||||
bail "invalid version format: '${version}'"
|
||||
fi
|
||||
if [[ "${2:-}" == "--dry-run" ]]; then
|
||||
dry_run="--dry-run"
|
||||
shift
|
||||
fi
|
||||
if [[ $# -gt 1 ]]; then
|
||||
bail "invalid argument: '$2'"
|
||||
fi
|
||||
|
||||
if [[ -z "${dry_run:-}" ]]; then
|
||||
git diff --exit-code
|
||||
git diff --exit-code --staged
|
||||
fi
|
||||
|
||||
# Make sure that a valid release note for this version exists.
|
||||
# https://github.com/taiki-e/parse-changelog
|
||||
echo "============== CHANGELOG =============="
|
||||
parse-changelog CHANGELOG.md "${version}"
|
||||
echo "======================================="
|
||||
|
||||
# Make sure the same release has not been created in the past.
|
||||
if gh release view "${tag}" &>/dev/null; then
|
||||
bail "tag '${tag}' has already been created and pushed"
|
||||
fi
|
||||
|
||||
# Exit if dry run.
|
||||
if [[ -n "${dry_run:-}" ]]; then
|
||||
warn "skip creating a new tag '${tag}' due to dry run"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
info "creating and pushing a new tag '${tag}'"
|
||||
|
||||
(
|
||||
set -x
|
||||
|
||||
git push origin main
|
||||
git tag "${tag}"
|
||||
git push origin --tags
|
||||
sleep 10
|
||||
|
||||
version_tag=v1
|
||||
version_tag="v${version%%.*}"
|
||||
git checkout -b "${version_tag}"
|
||||
git push origin -f refs/heads/"${version_tag}"
|
||||
git push origin refs/heads/"${version_tag}"
|
||||
if git --no-pager tag | grep -E "^${version_tag}$" &>/dev/null; then
|
||||
git tag -d "${version_tag}"
|
||||
git push --delete origin refs/tags/"${version_tag}"
|
||||
|
||||
Reference in New Issue
Block a user