Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches: [ "**" ]
pull_request:
branches: [ "**" ]

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'

- name: Cache Dependencies
uses: actions/cache@v3
id: gomod-cache
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }}
restore-keys: |
${{ runner.os }}-go-

- name: Install Dependencies
run: go mod tidy

- name: Lint
run: |
go install golang.org/x/lint/golint@latest
golint ./...

- name: Format Check
run: |
unformatted=$(go fmt ./...)
if [ -n "$unformatted" ]; then
echo "The following files are not formatted:"
echo "$unformatted"
exit 1
else
echo "Code is formatted."
fi

- name: Vet
run: go vet ./...

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
23 changes: 3 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ on:
workflows: ["CI"]
types:
- completed
push:
branches:
- stable
tags:
- v*

permissions:
contents: write

jobs:
release:
if: |
(github.event.workflow_run.conclusion == 'success' && github.event_name == 'workflow_run') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -35,19 +27,10 @@ jobs:
with:
go-version: '1.23'

- name: Check formatting (go fmt)
run: |
out=$(go fmt ./...)
if [ -n "$out" ]; then
echo "The following files are not gofmt'ed:" >&2
echo "$out" >&2
exit 1
fi

- name: Build for Multiple Platforms
run: |
mkdir -p releases
PLATFORMS=("windows/amd64" "linux/amd64" "darwin/amd64" "darwin/arm64")
PLATFORMS=("windows/amd64" "linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64")
for platform in "${PLATFORMS[@]}"; do
OS=${platform%/*}
ARCH=${platform#*/}
Expand All @@ -74,4 +57,4 @@ jobs:
files: |
releases/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading