diff --git a/.github/workflows/install-script-test.yml b/.github/workflows/install-script-test.yml new file mode 100644 index 000000000..ab07899b5 --- /dev/null +++ b/.github/workflows/install-script-test.yml @@ -0,0 +1,35 @@ +name: Test installation + +on: + push: + branches: + - main + pull_request: + paths: + - "release_files/install.sh" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.actor_id }} + cancel-in-progress: true +jobs: + test-install-script: + strategy: + max-parallel: 2 + matrix: + os: [ubuntu-latest, macos-latest] + skip_ui_mode: [true, false] + install_binary: [true, false] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: run install script + env: + SKIP_UI_APP: ${{ matrix.skip_ui_mode }} + USE_BIN_INSTALL: ${{ matrix.install_binary }} + run: | + [ "$SKIP_UI_APP" == "false" ] && export XDG_CURRENT_DESKTOP="none" + cat release_files/install.sh | sh -x + + - name: check cli binary + run: command -v netbird diff --git a/.github/workflows/install-test-darwin.yml b/.github/workflows/install-test-darwin.yml deleted file mode 100644 index 9fede3438..000000000 --- a/.github/workflows/install-test-darwin.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Test installation Darwin - -on: - push: - branches: - - main - pull_request: - paths: - - "release_files/install.sh" -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.actor_id }} - cancel-in-progress: true -jobs: - install-cli-only: - runs-on: macos-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Rename brew package - if: ${{ matrix.check_bin_install }} - run: mv /opt/homebrew/bin/brew /opt/homebrew/bin/brew.bak - - - name: Run install script - run: | - sh ./release_files/install.sh - env: - SKIP_UI_APP: true - - - name: Run tests - run: | - if ! command -v netbird &> /dev/null; then - echo "Error: netbird is not installed" - exit 1 - fi - install-all: - runs-on: macos-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Rename brew package - if: ${{ matrix.check_bin_install }} - run: mv /opt/homebrew/bin/brew /opt/homebrew/bin/brew.bak - - - name: Run install script - run: | - sh ./release_files/install.sh - - - name: Run tests - run: | - if ! command -v netbird &> /dev/null; then - echo "Error: netbird is not installed" - exit 1 - fi - - if [[ $(mdfind "kMDItemContentType == 'com.apple.application-bundle' && kMDItemFSName == '*NetBird UI.app'") ]]; then - echo "Error: NetBird UI is not installed" - exit 1 - fi diff --git a/.github/workflows/install-test-linux.yml b/.github/workflows/install-test-linux.yml deleted file mode 100644 index 4ce30a937..000000000 --- a/.github/workflows/install-test-linux.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Test installation Linux - -on: - push: - branches: - - main - pull_request: - paths: - - "release_files/install.sh" -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.actor_id }} - cancel-in-progress: true -jobs: - install-cli-only: - runs-on: ubuntu-latest - strategy: - matrix: - check_bin_install: [true, false] - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Rename apt package - if: ${{ matrix.check_bin_install }} - run: | - sudo mv /usr/bin/apt /usr/bin/apt.bak - sudo mv /usr/bin/apt-get /usr/bin/apt-get.bak - - - name: Run install script - run: | - sh ./release_files/install.sh - - - name: Run tests - run: | - if ! command -v netbird &> /dev/null; then - echo "Error: netbird is not installed" - exit 1 - fi diff --git a/.github/workflows/test-infrastructure-files.yml b/.github/workflows/test-infrastructure-files.yml index 3861487c2..fdebc882e 100644 --- a/.github/workflows/test-infrastructure-files.yml +++ b/.github/workflows/test-infrastructure-files.yml @@ -9,7 +9,6 @@ on: - 'infrastructure_files/**' - '.github/workflows/test-infrastructure-files.yml' - concurrency: group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || github.actor_id }} cancel-in-progress: true diff --git a/release_files/install.sh b/release_files/install.sh index 63b8d81c3..971c074b6 100644 --- a/release_files/install.sh +++ b/release_files/install.sh @@ -24,13 +24,21 @@ download_release_binary() { VERSION=$(get_latest_release) BASE_URL="https://github.com/${OWNER}/${REPO}/releases/download" BINARY_BASE_NAME="${VERSION#v}_${OS_TYPE}_${ARCH}.tar.gz" - + # for Darwin, download the signed Netbird-UI if [ "$OS_TYPE" = "darwin" ] && [ "$1" = "$UI_APP" ]; then BINARY_BASE_NAME="${VERSION#v}_${OS_TYPE}_${ARCH}_signed.zip" fi - BINARY_NAME="$1_${BINARY_BASE_NAME}" + if [ "$1" = "$UI_APP" ]; then + BINARY_NAME="$1-${OS_TYPE}_${BINARY_BASE_NAME}" + if [ "$OS_TYPE" = "darwin" ]; then + BINARY_NAME="$1_${BINARY_BASE_NAME}" + fi + else + BINARY_NAME="$1_${BINARY_BASE_NAME}" + fi + DOWNLOAD_URL="${BASE_URL}/${VERSION}/${BINARY_NAME}" echo "Installing $1 from $DOWNLOAD_URL" @@ -128,6 +136,14 @@ install_native_binaries() { fi } +check_use_bin_variable() { + if [ "${USE_BIN_INSTALL}-x" = "true-x" ]; then + echo "The installation will be performed using binary files" + return 0 + fi + return 1 +} + install_netbird() { # Check if netbird CLI is installed if [ -x "$(command -v netbird)" ]; then @@ -170,8 +186,10 @@ install_netbird() { echo "Netbird UI installation will be omitted as Linux does not run desktop environment" fi - # Check the availability of a compactible package manager - if [ -x "$(command -v apt)" ]; then + # Check the availability of a compatible package manager + if check_use_bin_variable; then + PACKAGE_MANAGER="bin" + elif [ -x "$(command -v apt)" ]; then PACKAGE_MANAGER="apt" echo "The installation will be performed using apt package manager" elif [ -x "$(command -v dnf)" ]; then @@ -191,7 +209,9 @@ install_netbird() { INSTALL_DIR="/usr/local/bin" # Check the availability of a compatible package manager - if [ -x "$(command -v brew)" ]; then + if check_use_bin_variable; then + PACKAGE_MANAGER="bin" + elif [ -x "$(command -v brew)" ]; then PACKAGE_MANAGER="brew" echo "The installation will be performed using brew package manager" fi