ci: migrate from Woodpecker CI to Forgejo Actions #1
9 changed files with 186 additions and 102 deletions
48
.github/workflows/ci.yml
vendored
Normal file
48
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
format:
|
||||||
|
runs-on: docker
|
||||||
|
container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
- run: make format
|
||||||
|
- run: git diff --exit-code
|
||||||
|
|
||||||
|
goreleaser-lint:
|
||||||
|
runs-on: docker
|
||||||
|
container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/goreleaser-action@v6.4.0
|
||||||
|
with:
|
||||||
|
args: check
|
||||||
|
|
||||||
|
lint:
|
||||||
|
runs-on: docker
|
||||||
|
container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
- run: make ci-lint
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: docker
|
||||||
|
container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
- run: make build-nodata
|
||||||
36
.github/workflows/release.yml
vendored
Normal file
36
.github/workflows/release.yml
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ["v*"]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: docker
|
||||||
|
container: git.nakama.town/fmartingr/ci-images/ci-base:1.0.0
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@v6
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
- name: Clone data repository
|
||||||
|
run: git clone https://fmartingr:${{ secrets.FORGEJO_TOKEN }}@git.nakama.town/fmartingr/terraria-companion-data.git data
|
||||||
|
|
||||||
|
- name: Setup Docker buildx
|
||||||
|
run: docker buildx create --use --name multiplatform --driver docker-container
|
||||||
|
|
||||||
|
- name: Login to container registry
|
||||||
|
run: echo "${{ secrets.FORGEJO_TOKEN }}" | docker login git.nakama.town -u ${{ github.actor }} --password-stdin
|
||||||
|
|
||||||
|
- name: Run GoReleaser
|
||||||
|
uses: actions/goreleaser-action@v6.4.0
|
||||||
|
with:
|
||||||
|
args: release --clean
|
||||||
|
env:
|
||||||
|
GORELEASER_FORCE_TOKEN: gitea
|
||||||
|
GITEA_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
13
.gitignore
vendored
13
.gitignore
vendored
|
|
@ -6,5 +6,18 @@ server.log
|
||||||
terraria-companion
|
terraria-companion
|
||||||
terraria-companion-*
|
terraria-companion-*
|
||||||
dist/
|
dist/
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Data
|
||||||
/data
|
/data
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
.env
|
||||||
|
|
||||||
|
# Coverage
|
||||||
|
coverage.html
|
||||||
|
coverage.out
|
||||||
|
|
||||||
|
# AI tools
|
||||||
|
.claude/
|
||||||
|
.cursor/
|
||||||
|
|
|
||||||
|
|
@ -44,25 +44,31 @@ dockers_v2:
|
||||||
- linux/arm64
|
- linux/arm64
|
||||||
|
|
||||||
checksum:
|
checksum:
|
||||||
name_template: "checksums.txt"
|
name_template: checksums.txt
|
||||||
|
|
||||||
snapshot:
|
|
||||||
version_template: "{{ incpatch .Version }}-next"
|
|
||||||
|
|
||||||
changelog:
|
changelog:
|
||||||
sort: asc
|
sort: asc
|
||||||
groups:
|
groups:
|
||||||
- title: Features
|
- title: Features
|
||||||
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
|
regexp: "^.*feat.*$"
|
||||||
order: 0
|
order: 0
|
||||||
- title: "Fixes"
|
- title: Bug Fixes
|
||||||
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
|
regexp: "^.*fix.*$"
|
||||||
order: 1
|
order: 1
|
||||||
|
- title: Performance
|
||||||
|
regexp: "^.*perf.*$"
|
||||||
|
order: 2
|
||||||
|
- title: Documentation
|
||||||
|
regexp: "^.*docs.*$"
|
||||||
|
order: 3
|
||||||
|
- title: CI/CD
|
||||||
|
regexp: "^.*ci.*$"
|
||||||
|
order: 4
|
||||||
- title: Others
|
- title: Others
|
||||||
order: 999
|
order: 999
|
||||||
filters:
|
|
||||||
exclude:
|
|
||||||
- "^chore\\(deps\\):"
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
|
gitea:
|
||||||
|
owner: fmartingr
|
||||||
|
name: terraria-companion
|
||||||
prerelease: auto
|
prerelease: auto
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- push
|
|
||||||
- pull_request
|
|
||||||
branch:
|
|
||||||
- main
|
|
||||||
|
|
||||||
steps:
|
|
||||||
format:
|
|
||||||
image: golang:1.24
|
|
||||||
commands:
|
|
||||||
- test -z "$(gofmt -l .)"
|
|
||||||
|
|
||||||
lint:
|
|
||||||
image: golangci/golangci-lint:latest
|
|
||||||
commands:
|
|
||||||
- golangci-lint run ./...
|
|
||||||
|
|
||||||
build:
|
|
||||||
image: golang:1.24
|
|
||||||
commands:
|
|
||||||
- go build -v ./...
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
when:
|
|
||||||
- event: tag
|
|
||||||
branch: main
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Release
|
|
||||||
image: git.nakama.town/fmartingr/ci-images/ci-release:latest
|
|
||||||
environment:
|
|
||||||
GITEA_TOKEN:
|
|
||||||
from_secret: GITEA_TOKEN
|
|
||||||
DOCKER_HOST: unix:///var/run/docker.sock
|
|
||||||
volumes:
|
|
||||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
|
||||||
commands:
|
|
||||||
# Clone data repository
|
|
||||||
- git clone https://fmartingr:$GITEA_TOKEN@git.nakama.town/fmartingr/terraria-companion-data.git data
|
|
||||||
|
|
||||||
# Setup Docker buildx
|
|
||||||
- docker buildx create --use --name multiplatform --driver docker-container
|
|
||||||
|
|
||||||
# Authenticate and release
|
|
||||||
- docker login -u fmartingr -p $GITEA_TOKEN git.nakama.town
|
|
||||||
- goreleaser release --clean
|
|
||||||
|
|
@ -1,20 +1,23 @@
|
||||||
FROM alpine:3.21
|
# Build dependencies on native arch (no QEMU needed)
|
||||||
|
FROM --platform=$BUILDPLATFORM alpine:3.23 AS base
|
||||||
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
|
RUN addgroup -g 1000 app && adduser -D -u 1000 -G app app
|
||||||
|
RUN mkdir /app && chown app:app /app
|
||||||
|
|
||||||
|
# Runtime image
|
||||||
|
FROM scratch
|
||||||
LABEL maintainer="Felipe Martin <me@fmartingr.com>"
|
LABEL maintainer="Felipe Martin <me@fmartingr.com>"
|
||||||
LABEL org.opencontainers.image.source="https://git.nakama.town/fmartingr/terraria-companion"
|
LABEL org.opencontainers.image.source="https://git.nakama.town/fmartingr/terraria-companion"
|
||||||
|
|
||||||
RUN apk add --no-cache ca-certificates tzdata
|
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||||
|
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
|
||||||
RUN addgroup -g 1000 app && \
|
COPY --from=base /etc/passwd /etc/passwd
|
||||||
adduser -D -u 1000 -G app app
|
COPY --from=base /etc/group /etc/group
|
||||||
|
COPY --from=base /app /app
|
||||||
|
COPY terraria-companion /usr/local/bin/terraria-companion
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
|
||||||
COPY ${TARGETPLATFORM}/terraria-companion /usr/local/bin/terraria-companion
|
|
||||||
RUN chmod +x /usr/local/bin/terraria-companion && \
|
|
||||||
mkdir -p /app/data /app/data/icons && \
|
|
||||||
chown -R app:app /app
|
|
||||||
|
|
||||||
USER app
|
USER app
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
|
||||||
83
Makefile
83
Makefile
|
|
@ -1,69 +1,92 @@
|
||||||
BINARY_NAME := terraria-companion
|
PROJECT_NAME := terraria-companion
|
||||||
|
CGO_ENABLED ?= 0
|
||||||
PORT ?= 3000
|
PORT ?= 3000
|
||||||
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||||
LDFLAGS := -X main.version=$(VERSION)
|
LDFLAGS := -X main.version=$(VERSION)
|
||||||
|
|
||||||
|
GOLANGCI_LINT_VERSION := v1.64.5
|
||||||
|
|
||||||
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
|
## help: Display this help message
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
@echo "Available targets:"
|
||||||
|
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /' | sort
|
||||||
|
|
||||||
# ── Build ────────────────────────────────────────────────────────
|
# ── Build ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
## build: Build the production binary (embeds data assets)
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: ## Build the production binary (embeds data assets)
|
build:
|
||||||
go build -tags embed_data -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) .
|
CGO_ENABLED=$(CGO_ENABLED) go build -tags embed_data -ldflags "$(LDFLAGS)" -o $(PROJECT_NAME) .
|
||||||
|
|
||||||
|
## build-nodata: Build without embedded data (for CI/containers)
|
||||||
.PHONY: build-nodata
|
.PHONY: build-nodata
|
||||||
build-nodata: ## Build without embedded data (for CI/containers)
|
build-nodata:
|
||||||
go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) .
|
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags "$(LDFLAGS)" -o $(PROJECT_NAME) .
|
||||||
|
|
||||||
|
## build-snapshot: Build all platforms locally via goreleaser (snapshot)
|
||||||
.PHONY: build-snapshot
|
.PHONY: build-snapshot
|
||||||
build-snapshot: ## Build all platforms locally via goreleaser (snapshot)
|
build-snapshot:
|
||||||
goreleaser build --snapshot --clean
|
goreleaser build --snapshot --clean
|
||||||
|
|
||||||
# ── Development ──────────────────────────────────────────────────
|
# ── Development ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
## dev: Run in dev mode (serves frontend from disk, hot-reloads data)
|
||||||
.PHONY: dev
|
.PHONY: dev
|
||||||
dev: ## Run in dev mode (serves frontend from disk, hot-reloads data)
|
dev:
|
||||||
DEV=1 go run .
|
DEV=1 go run .
|
||||||
|
|
||||||
|
## serve: Build and run the production server
|
||||||
.PHONY: serve
|
.PHONY: serve
|
||||||
serve: build ## Build and run the production server
|
serve: build
|
||||||
./$(BINARY_NAME)
|
./$(PROJECT_NAME)
|
||||||
|
|
||||||
# ── Data Fetching ────────────────────────────────────────────────
|
# ── Data Fetching ────────────────────────────────────────────────
|
||||||
|
|
||||||
|
## fetch: Fetch/resume data from Terraria wiki (Go fetcher)
|
||||||
.PHONY: fetch
|
.PHONY: fetch
|
||||||
fetch: ## Fetch/resume data from Terraria wiki (Go fetcher)
|
fetch:
|
||||||
go run . fetch
|
go run . fetch
|
||||||
|
|
||||||
|
## fetch-reset: Reset fetch state and start fresh
|
||||||
.PHONY: fetch-reset
|
.PHONY: fetch-reset
|
||||||
fetch-reset: ## Reset fetch state and start fresh
|
fetch-reset:
|
||||||
go run . fetch --reset
|
go run . fetch --reset
|
||||||
|
|
||||||
|
## fetch-only: Fetch a single phase (usage: make fetch-only PHASE=drops)
|
||||||
.PHONY: fetch-only
|
.PHONY: fetch-only
|
||||||
fetch-only: ## Fetch a single phase (usage: make fetch-only PHASE=drops)
|
fetch-only:
|
||||||
go run . fetch --only=$(PHASE)
|
go run . fetch --only=$(PHASE)
|
||||||
|
|
||||||
# ── Quality ──────────────────────────────────────────────────────
|
# ── Quality ──────────────────────────────────────────────────────
|
||||||
.PHONY: format
|
|
||||||
format: ## Format Go source files
|
|
||||||
gofmt -w .
|
|
||||||
|
|
||||||
.PHONY: lint
|
## format: Format code and tidy modules
|
||||||
lint: ## Run linter
|
.PHONY: format
|
||||||
|
format:
|
||||||
|
go fmt ./...
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
## ci-lint: Run linter (auto-installs golangci-lint for CI)
|
||||||
|
.PHONY: ci-lint
|
||||||
|
ci-lint:
|
||||||
|
@which golangci-lint > /dev/null 2>&1 || go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
|
||||||
golangci-lint run ./...
|
golangci-lint run ./...
|
||||||
|
|
||||||
.PHONY: ci-lint
|
## lint: Run linters
|
||||||
ci-lint: ## Run linter with colored output (for CI)
|
.PHONY: lint
|
||||||
golangci-lint run --out-format colored-line-number ./...
|
lint: ci-lint
|
||||||
|
|
||||||
# ── Cleanup ──────────────────────────────────────────────────────
|
# ── Cleanup ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
## clean: Remove build artifacts
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: ## Remove build artifacts
|
clean:
|
||||||
rm -f $(BINARY_NAME) $(BINARY_NAME)-*
|
rm -f $(PROJECT_NAME) $(PROJECT_NAME)-*
|
||||||
rm -rf dist/
|
rm -rf dist/
|
||||||
|
|
||||||
|
## clean-data: Remove fetched data (keeps icons as cache)
|
||||||
.PHONY: clean-data
|
.PHONY: clean-data
|
||||||
clean-data: ## Remove fetched data (keeps icons as cache)
|
clean-data:
|
||||||
rm -rf data
|
rm -rf data
|
||||||
|
|
||||||
# ── Help ─────────────────────────────────────────────────────────
|
|
||||||
.PHONY: help
|
|
||||||
help: ## Show this help
|
|
||||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
|
|
||||||
|
|
||||||
.DEFAULT_GOAL := help
|
|
||||||
|
|
|
||||||
14
server.go
14
server.go
|
|
@ -100,13 +100,13 @@ type StatusResponse struct {
|
||||||
// ── DataStore ───────────────────────────────────────────────────
|
// ── DataStore ───────────────────────────────────────────────────
|
||||||
|
|
||||||
type DataStore struct {
|
type DataStore struct {
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
items []Item
|
items []Item
|
||||||
itemsByName map[string]Item
|
itemsByName map[string]Item
|
||||||
recipesByResult map[string][]Recipe
|
recipesByResult map[string][]Recipe
|
||||||
recipesByIngredient map[string][]Recipe
|
recipesByIngredient map[string][]Recipe
|
||||||
dropsByItem map[string][]Drop
|
dropsByItem map[string][]Drop
|
||||||
splashes []string
|
splashes []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func sanitizeImagefile(name string) string {
|
func sanitizeImagefile(name string) string {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue