From 918da68b1fc678a974e35527c9af72ada162bb10 Mon Sep 17 00:00:00 2001 From: nullswan Date: Mon, 21 Oct 2024 10:55:26 +0200 Subject: [PATCH] ci(release): unify dependency installation script --- .github/workflows/release.yml | 38 ++++++++--------------------------- hack/install-deps.sh | 30 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 hack/install-deps.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4a9f5f0..20dbda5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,41 +23,19 @@ jobs: with: go-version-file: go.mod - - name: Install Dependencies (Linux) - if: runner.os == 'Linux' - run: | - sudo apt-get update - # gcc - sudo apt install -y gcc libc6-dev - # x11 - sudo apt install -y libx11-dev xorg-dev libxtst-dev - # Clipboard - sudo apt install -y xsel xclip - # Bitmap - sudo apt install -y libpng++-dev - # GoHook - sudo apt install -y xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libxkbcommon-dev - # portaudio - sudo apt-get install -y portaudio19-dev - go mod download - - - name: Install Dependencies (macOS) - if: runner.os == 'macOS' - run: | - brew install portaudio - go mod download - - - name: Install Dependencies (Windows) - if: runner.os == 'Windows' - run: | - choco install portaudio - go mod download + - name: Install Dependencies + run: bash hack/install-deps.sh - name: Build Binary + shell: bash env: CGO_ENABLED: 1 + PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }} run: | - go build -o nomi-cli ./cmd/cli -ldflags "-X main.buildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -X main.buildVersion=${GITHUB_REF#refs/tags/}" + go build \ + -ldflags "-X main.buildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ + -X main.buildVersion=${{ github.ref_name }}" \ + -o nomi-cli ./cmd/cli - name: Archive Binary (Windows) if: runner.os == 'Windows' diff --git a/hack/install-deps.sh b/hack/install-deps.sh new file mode 100644 index 0000000..36ef5c0 --- /dev/null +++ b/hack/install-deps.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -e + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + sudo apt-get update + # gcc + sudo apt install -y gcc libc6-dev + # x11 + sudo apt install -y libx11-dev xorg-dev libxtst-dev + # Clipboard + sudo apt install -y xsel xclip + # Bitmap + sudo apt install -y libpng++-dev + # GoHook + sudo apt install -y xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x11-dev libxkbcommon-dev + # portaudio + sudo apt-get install -y portaudio19-dev + go mod download +elif [[ "$OSTYPE" == "darwin"* ]]; then + brew install portaudio + go mod download +elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then + pip install pipwin + pipwin install pyaudio + go mod download +else + echo "Unsupported OS" + exit 1 +fi