71 lines
1.4 KiB
YAML
71 lines
1.4 KiB
YAML
variables:
|
|
- &golang_image 'golang:1.24'
|
|
|
|
steps:
|
|
backend-lint:
|
|
image: *golang_image
|
|
group: lint
|
|
commands:
|
|
- go vet ./...
|
|
- go fmt ./...
|
|
|
|
frontend-lint:
|
|
image: node:20
|
|
group: lint
|
|
commands:
|
|
- cd web
|
|
- npm ci
|
|
- npm run lint
|
|
|
|
frontend-build:
|
|
image: node:20
|
|
commands:
|
|
- cd web
|
|
- npm ci
|
|
- npm run build
|
|
depends_on:
|
|
- frontend-lint
|
|
when:
|
|
status: [success]
|
|
|
|
backend-build:
|
|
image: *golang_image
|
|
commands:
|
|
- go mod download
|
|
- go generate ./...
|
|
# Build with embedded frontend
|
|
- go build -o inventory -ldflags="-s -w" .
|
|
depends_on:
|
|
- frontend-build
|
|
- backend-lint
|
|
when:
|
|
status: [success]
|
|
|
|
# Create artifacts
|
|
artifacts:
|
|
image: alpine:latest
|
|
commands:
|
|
- mkdir -p artifacts
|
|
- cp inventory artifacts/
|
|
- tar -czvf artifacts/inventory.tar.gz inventory
|
|
depends_on:
|
|
- backend-build
|
|
when:
|
|
status: [success]
|
|
|
|
# Optional step for creating a Docker image
|
|
docker-build:
|
|
image: plugins/docker
|
|
settings:
|
|
repo: ${DRONE_REPO_OWNER}/inventory
|
|
tags:
|
|
- latest
|
|
- ${DRONE_TAG##v}
|
|
dockerfile: Dockerfile
|
|
depends_on:
|
|
- backend-lint
|
|
- frontend-lint
|
|
when:
|
|
branch: main
|
|
event: [push, tag]
|
|
status: [success]
|