diff --git a/publish b/publish deleted file mode 100755 index 7532a1a..0000000 --- a/publish +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash -set -euo pipefail - -BASE_DIR="$(cd "$(dirname "$0")"; pwd)" -NUPKG_BASENAME='Dena.CodeAnalysis.Testing.nupkg' - - -throw() { - local msg="$*" - printf '%s\n' "$msg" 1>&2 - false -} - - -has() { - local cmd="$1" - which "$cmd" >/dev/null 2>&1 -} - - -usage() { - cat - 1>&2 <<-EOS -usage: publish [] - -OPTIONS - -h, --help print this help -EOS -} - - -get-version() { - (cd "$BASE_DIR" - grep -o '[^<]*' ./src/Dena.CodeAnalysis.Testing/Dena.CodeAnalysis.Testing.csproj | sed 's/\([^<]*\).*/\1/' - ) -} - - -validate-env() { - has dotnet || throw "dotnet must be installed (see https://docs.microsoft.com/ja-jp/dotnet/core/tools/)" -} - - -acquire-tag() { - (cd "$BASE_DIR" - local version="$1" - if (git tag | grep -Fqx "$version"); then - throw "a tag has the same name exists on local, so if still you want to overwrite the tag, please remove the tag on local and try again.: '$version'" - fi - git tag "$version" - ) -} - - -build() { - local dst="$1" - local version="$2" - - (cd "$BASE_DIR" - dotnet build --no-incremental - - local nupkg_orig - nupkg_orig="./src/Dena.CodeAnalysis.Testing/bin/Debug/Dena.CodeAnalysis.Testing.${version}.nupkg" - [[ -f "$nupkg_orig" ]] || throw "no .nupkg found at '$nupkg_orig'" - - cp "$nupkg_orig" "$dst" - ) -} - - -main() { - local arg="${1:-}" - if [[ "$arg" == "--help" ]] || [[ "$arg" == "-h" ]]; then - usage - false - fi - if [[ "$arg" == "--version" ]] || [[ "$arg" == "-v" ]]; then - get-version - exit 0 - fi - - validate-env - - local version - version="$(get-version)" - acquire-tag "$version" - - local nupkg="./${NUPKG_BASENAME}" - build "$nupkg" "$version" - - dotnet nuget push "$nupkg" -Source https://api.nuget.org/v3/index.json - git push origin "$version" -} - - -main "$@"