Skip to content

Commit

Permalink
ci(release): unify dependency installation script
Browse files Browse the repository at this point in the history
  • Loading branch information
nullswan committed Oct 21, 2024
1 parent 82ce25a commit 918da68
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 30 deletions.
38 changes: 8 additions & 30 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
30 changes: 30 additions & 0 deletions hack/install-deps.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 918da68

Please sign in to comment.