From b62a2dfda0ed266502f7c71f7ce79f8fd9c26bf6 Mon Sep 17 00:00:00 2001 From: Yevhen Fabizhevskyi Date: Thu, 17 Nov 2022 22:42:21 +0900 Subject: [PATCH] installation: fix installation on Windows (#307) --- .github/workflows/test-install.yaml | 29 +++++++++++++++++++++++++++++ install.sh | 26 +++++++++----------------- 2 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/test-install.yaml diff --git a/.github/workflows/test-install.yaml b/.github/workflows/test-install.yaml new file mode 100644 index 00000000..612da005 --- /dev/null +++ b/.github/workflows/test-install.yaml @@ -0,0 +1,29 @@ +--- +name: Test install.sh + +on: + pull_request: + paths: + - .github/workflows/test-install.yaml + - install.sh + +jobs: + test-install-sh: + name: Test install.sh + strategy: + fail-fast: false + matrix: + os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Install multi-gitter + env: + BINDIR: ${{ github.workspace }}/bin + run: | + curl -s https://raw.githubusercontent.com/${{ github.event.pull_request.head.repo.full_name }}/${{ github.head_ref }}/install.sh | sh -s -- -d + echo "${{ github.workspace }}/bin" >> $GITHUB_PATH + shell: sh + - name: Print version + run: multi-gitter version + shell: sh diff --git a/install.sh b/install.sh index 440c9912..aa5a89dd 100644 --- a/install.sh +++ b/install.sh @@ -8,7 +8,7 @@ usage() { $this: download go binaries for lindell/multi-gitter Usage: $this [-b] bindir [-d] [tag] - -b sets bindir or installation directory, Defaults to ./bin + -b sets bindir or installation directory, Defaults to /usr/local/bin -d turns on debug logging [tag] is a tag from https://github.com/lindell/multi-gitter/releases @@ -51,14 +51,15 @@ execute() { (cd "${tmpdir}" && untar "${TARBALL}") test ! -d "${BINDIR}" && install -d "${BINDIR}" for binexe in $BINARIES; do - if [ "$OS" = "windows" ]; then - binexe="${binexe}.exe" - fi - if test -w "${BINDIR}/${binexe}"; then - install "${srcdir}/${binexe}" "${BINDIR}/${binexe}" + if [ "$OS" = "Windows" ]; then + install "${srcdir}/${binexe}.exe" "${BINDIR}/${binexe}.exe" else - log_info "not allowed to install binary without higher privilege" - sudo install "${srcdir}/${binexe}" "${BINDIR}/${binexe}" + if test -w "${BINDIR}/${binexe}"; then + install "${srcdir}/${binexe}" "${BINDIR}/${binexe}" + else + log_info "not allowed to install binary without higher privilege" + sudo install "${srcdir}/${binexe}" "${BINDIR}/${binexe}" + fi fi log_info "installed ${BINDIR}/${binexe}" done @@ -99,13 +100,6 @@ tag_to_version() { TAG="$REALTAG" VERSION=${TAG#v} } -adjust_format() { - # change format based on OS - case ${OS} in - windows) FORMAT=.exe ;; - esac - true -} adjust_os() { # adjust archive name based on OS case ${OS} in @@ -388,8 +382,6 @@ get_binaries tag_to_version -adjust_format - adjust_os adjust_arch