fix: #4 make script install with portability #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release Binaries for Linux (amd64, arm64), MacOS (Silicon arm64) and Windows (amd64) | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
tags: | |
- 'v*' | |
pull_request: | |
env: | |
GO_VERSION: 1.22 | |
APP_NAME: wazuh-agent-status | |
jobs: | |
build-linux: | |
name: Build for Linux (amd64, arm64) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: [amd64] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Install Linux dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
libayatana-appindicator3-dev \ | |
libdbusmenu-glib-dev \ | |
libgtk-3-dev \ | |
libharfbuzz-dev \ | |
libpango1.0-dev \ | |
libcairo2-dev \ | |
libgdk-pixbuf2.0-dev \ | |
libatk1.0-dev | |
- name: Build binary | |
run: | | |
GOOS=linux GOARCH=${{ matrix.arch }} go build -o dist/${{ env.APP_NAME }}-linux-${{ matrix.arch }} | |
- name: Upload Linux binary | |
if: ${{ !env.ACT }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.APP_NAME }}-linux-${{ matrix.arch }} | |
path: ./dist/ | |
build-macos: | |
name: Build for macOS ARM64 | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
arch: [arm64] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Install MacOS Dependencies | |
run: | | |
brew install gtk+3 | |
- name: Build binary for macOS Silicon (ARM64) | |
run: | | |
GOOS=darwin GOARCH=${{ matrix.arch }} go build -o dist/${{ env.APP_NAME }}-darwin-${{ matrix.arch }} | |
- name: Upload macOS binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.APP_NAME }}-darwin-${{ matrix.arch }} | |
path: ./dist/ | |
build-windows: | |
name: Build for Windows AMD64 | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
arch: [amd64] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Install Dependencies | |
run: | | |
go mod tidy | |
- name: Build binary for Windows | |
run: | | |
go build -o dist/${{ env.APP_NAME }}-windows-${{ matrix.arch }}.exe | |
- name: Upload Windows binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.APP_NAME }}-windows-${{ matrix.arch }} | |
path: ./dist/ | |
release: | |
name: Release | |
permissions: write-all | |
needs: | |
- build-linux | |
- build-macos | |
- build-windows | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get the version | |
id: get_version | |
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
if: startsWith(github.ref, 'refs/tags/v') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_version.outputs.VERSION }} | |
release_name: Release ${{ steps.get_version.outputs.VERSION }} | |
draft: false | |
prerelease: false | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./dist | |
- name: Create Release and Upload Assets | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/v') | |
with: | |
files: '**' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |