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
59 changes: 37 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,26 @@ on:
pull_request:
branches: [ main, develop ]

env:
GO_VERSION: '1.25.x'

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
go-version: [1.23.x]

steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: go.sum

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
${{ runner.os }}-go-
- name: Verify dependencies
run: go mod verify

- name: Install dependencies
run: go mod download
Expand Down Expand Up @@ -129,22 +123,43 @@ jobs:
body: coverage
});
}

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

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.23.x
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: go.sum

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --out-format=colored-line-number
args: --out-format=colored-line-number --timeout=5m

build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache: true
cache-dependency-path: go.sum

- name: Build application
run: go build -v -ldflags="-w -s" -o pico-api-go ./cmd/main.go

- name: Verify binary
run: |
file pico-api-go
echo "Binary size: $(du -h pico-api-go | cut -f1)"
10 changes: 7 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ jobs:
create-release:
runs-on: ubuntu-latest
needs: build-and-deploy
if: needs.build-and-deploy.result == 'success'
if: needs.build-and-deploy.result == 'success' && github.event_name == 'push'
permissions:
contents: write

Expand All @@ -282,7 +282,11 @@ jobs:
- name: Get version and release info
id: release_info
run: |
VERSION=${GITHUB_REF#refs/tags/}
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.tag }}" ]; then
VERSION="${{ github.event.inputs.tag }}"
else
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT

# Check if this is a hotfix or regular release
Expand Down Expand Up @@ -401,4 +405,4 @@ jobs:
else
echo "❌ Deployment failed for ${{ github.ref_name }}"
exit 1
fi
fi
Loading