Compare commits

...

8 Commits

Author SHA1 Message Date
Taiki Endo
f4abeafc99 Release 1.0.2 2022-01-06 00:40:44 +09:00
Taiki Endo
0180de5ee1 Update cargo-minimal-versions to 0.1.1 2022-01-06 00:37:50 +09:00
Taiki Endo
008e9ca06e Fix changelog 2022-01-06 00:25:18 +09:00
Taiki Endo
4d0d5ef7c9 Release 1.0.1 2022-01-05 22:45:21 +09:00
Taiki Endo
56a03286db Do not dynamically get latest version number
This fixes error in cases where the release has been created but the
binary has not yet been uploaded.
2022-01-05 22:41:37 +09:00
Taiki Endo
fc57aaa8ad Update tools/publish.sh 2022-01-01 17:57:13 +09:00
Taiki Endo
996e798ea2 Update CI config 2021-12-30 21:55:39 +09:00
Taiki Endo
6132093ff5 Update tools/publish.sh 2021-12-30 21:55:24 +09:00
5 changed files with 76 additions and 75 deletions

View File

@@ -26,14 +26,14 @@ jobs:
- ubuntu-18.04 - ubuntu-18.04
tool: tool:
- cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,shellcheck,shfmt - 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: include:
- os: macos-10.15 - 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 - os: windows-2019
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog
- os: windows-2019 - 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 }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@@ -49,9 +49,9 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
persist-credentials: false persist-credentials: false
- uses: taiki-e/github-actions/install@main - uses: taiki-e/install-action@shellcheck
with: - uses: taiki-e/install-action@shfmt
tool: prettier,shellcheck,shfmt - run: npm install prettier
- run: shfmt -d $(git ls-files '*.sh') - run: shfmt -d $(git ls-files '*.sh')
if: always() if: always()
- run: npx prettier -c $(git ls-files '*.yml') - run: npx prettier -c $(git ls-files '*.yml')

1
.gitignore vendored
View File

@@ -1,7 +1,6 @@
node_modules node_modules
package-lock.json package-lock.json
package.json package.json
tmp
# For platform and editor specific settings, it is recommended to add to # For platform and editor specific settings, it is recommended to add to
# a global .gitignore file. # a global .gitignore file.

View File

@@ -10,9 +10,19 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
## [Unreleased] ## [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 ## [1.0.0] - 2021-12-30
Initial release 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 [1.0.0]: https://github.com/taiki-e/install-action/releases/tag/v1.0.0

47
main.sh
View File

@@ -54,11 +54,18 @@ for tool in "${tools[@]}"; do
tool="${tool%@*}" tool="${tool%@*}"
info "installing ${tool}@${version}" info "installing ${tool}@${version}"
case "${tool}" in 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) 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}" repo="taiki-e/${tool}"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="x86_64-unknown-linux-musl" ;; linux*) target="x86_64-unknown-linux-musl" ;;
@@ -67,14 +74,15 @@ for tool in "${tools[@]}"; do
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
case "${version}" in case "${version}" in
latest) url="https://github.com/${repo}/releases/latest/download/${tool}-${target}.tar.gz" ;; latest) version="${latest_version}" ;;
*) url="https://github.com/${repo}/releases/download/v${version}/${tool}-${target}.tar.gz" ;;
esac 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}" \ retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" \
| tar xzf - -C ~/.cargo/bin | tar xzf - -C ~/.cargo/bin
;; ;;
# https://github.com/rust-embedded/cross/releases
cross) cross)
# https://github.com/rust-embedded/cross/releases
latest_version="0.2.1"
repo="rust-embedded/cross" repo="rust-embedded/cross"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="x86_64-unknown-linux-musl" ;; linux*) target="x86_64-unknown-linux-musl" ;;
@@ -83,15 +91,15 @@ for tool in "${tools[@]}"; do
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
case "${version}" in 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') ;; latest) version="${latest_version}" ;;
*) tag="v${version}" ;;
esac 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}" \ retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" \
| tar xzf - -C ~/.cargo/bin | tar xzf - -C ~/.cargo/bin
;; ;;
# https://github.com/koalaman/shellcheck/releases
shellcheck) shellcheck)
# https://github.com/koalaman/shellcheck/releases
latest_version="0.8.0"
repo="koalaman/shellcheck" repo="koalaman/shellcheck"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) linux*)
@@ -105,14 +113,15 @@ for tool in "${tools[@]}"; do
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
case "${version}" in 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')" ;; latest) version="${latest_version}" ;;
*) tag="v${version}" ;;
esac 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" \ url="https://github.com/${repo}/releases/download/v${version}/shellcheck-v${version}.${target}.x86_64.tar.xz"
| tar xJf - --strip-components 1 -C /usr/local/bin "shellcheck-${tag}/shellcheck" 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) shfmt)
# https://github.com/mvdan/sh/releases
latest_version="3.4.2"
repo="mvdan/sh" repo="mvdan/sh"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="linux_amd64" ;; linux*) target="linux_amd64" ;;
@@ -121,10 +130,10 @@ for tool in "${tools[@]}"; do
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
case "${version}" in 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')" ;; latest) version="${latest_version}" ;;
*) tag="v${version}" ;;
esac 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 chmod +x /usr/local/bin/shfmt
;; ;;
*) bail "unsupported tool '${tool}'" ;; *) bail "unsupported tool '${tool}'" ;;

View File

@@ -16,12 +16,35 @@ bail() {
echo >&2 "error: $*" echo >&2 "error: $*"
exit 1 exit 1
} }
warn() {
echo >&2 "warning: $*" version="${1:?}"
} version="${version#v}"
info() { tag="v${version}"
echo >&2 "info: $*" 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=( tools=(
cargo-hack cargo-hack
@@ -33,56 +56,16 @@ tools=(
shfmt 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 set -x
git push origin main git push origin main
git tag "${tag}" git tag "${tag}"
git push origin --tags git push origin --tags
sleep 10
version_tag=v1 version_tag="v${version%%.*}"
git checkout -b "${version_tag}" 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 if git --no-pager tag | grep -E "^${version_tag}$" &>/dev/null; then
git tag -d "${version_tag}" git tag -d "${version_tag}"
git push --delete origin refs/tags/"${version_tag}" git push --delete origin refs/tags/"${version_tag}"