[refactor]: simplify CI workflow #8
This file contains hidden or 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
# This workflow will build a golang project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
name: GoWebp CI | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
goos: linux | |
ext: "" | |
- os: windows-latest | |
goos: windows | |
ext: ".exe" | |
- os: macos-latest | |
goos: darwin | |
ext: "" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.24.1' | |
- name: Cache Go modules | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Install Linux build dependencies | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libgl1-mesa-dev xorg-dev | |
- name: Install macOS build dependencies | |
if: matrix.os == 'macos-latest' | |
run: | | |
brew install pkg-config | |
# - name: Run Tests | |
# run: go test -v ./... | |
- name: Build | |
run: | | |
CGO_ENABLED=1 GOOS=${{ matrix.goos }} GOARCH=amd64 go build -o GoWebp-${{ matrix.goos }}${{ matrix.ext }} ./cmd/GoWebp | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: GoWebp-${{ matrix.goos }}${{ matrix.ext }} | |
path: GoWebp-${{ matrix.goos }}${{ matrix.ext }} |