新增 Github Actions
This commit is contained in:
24
.github/workflows/go-release.yml
vendored
Normal file
24
.github/workflows/go-release.yml
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
name: Go Release
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.25'
|
||||||
|
- name: Build releases
|
||||||
|
run: make releases
|
||||||
|
- name: Create GitHub Release
|
||||||
|
id: create_release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
files: dist/*.tar.gz
|
||||||
36
.github/workflows/go-test.yml
vendored
Normal file
36
.github/workflows/go-test.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
name: Go Test
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
paths:
|
||||||
|
- '**.go'
|
||||||
|
- 'go.mod'
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
paths:
|
||||||
|
- '**.go'
|
||||||
|
- 'go.mod'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.25'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: go mod download
|
||||||
|
|
||||||
|
- name: Run tests with coverage
|
||||||
|
run: go test -v -coverprofile=coverage.txt ./...
|
||||||
|
|
||||||
|
- uses: codecov/codecov-action@v5
|
||||||
|
with:
|
||||||
|
files: ./coverage.txt
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -62,3 +62,5 @@ fabric.properties
|
|||||||
|
|
||||||
config-local.yaml
|
config-local.yaml
|
||||||
gitea-pages
|
gitea-pages
|
||||||
|
*.zip
|
||||||
|
dist/
|
||||||
33
Makefile
33
Makefile
@@ -1,17 +1,46 @@
|
|||||||
GOPATH := $(shell go env GOPATH)
|
GOPATH := $(shell go env GOPATH)
|
||||||
|
GOARCH ?= $(shell go env GOARCH)
|
||||||
|
GOOS ?= $(shell go env GOOS)
|
||||||
|
|
||||||
|
|
||||||
|
ifeq ($(GOOS),windows)
|
||||||
|
GO_DIST_NAME := gitea-pages.exe
|
||||||
|
else
|
||||||
|
GO_DIST_NAME := gitea-pages
|
||||||
|
endif
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
@(test -f "$(GOPATH)/bin/gofumpt" || go install mvdan.cc/gofumpt@latest) && \
|
@(test -f "$(GOPATH)/bin/gofumpt" || go install mvdan.cc/gofumpt@latest) && \
|
||||||
"$(GOPATH)/bin/gofumpt" -l -w .
|
"$(GOPATH)/bin/gofumpt" -l -w .
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: release
|
||||||
|
release: dist/gitea-pages-$(GOOS)-$(GOARCH).tar.gz
|
||||||
|
|
||||||
|
dist/gitea-pages-$(GOOS)-$(GOARCH).tar.gz: $(shell find . -type f -name "*.go" ) go.mod go.sum
|
||||||
|
@echo Compile $@ via $(GO_DIST_NAME) && \
|
||||||
|
mkdir -p dist && \
|
||||||
|
rm -f dist/$(GO_DIST_NAME) && \
|
||||||
|
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o dist/$(GO_DIST_NAME) . && \
|
||||||
|
cd dist && \
|
||||||
|
tar zcf gitea-pages-$(GOOS)-$(GOARCH).tar.gz $(GO_DIST_NAME) ../LICENSE ../config.yaml ../errors.html.tmpl ../README.md ../README_*.md && \
|
||||||
|
rm -f $(GO_DIST_NAME)
|
||||||
|
|
||||||
gitea-pages: $(shell find . -type f -name "*.go" ) go.mod go.sum
|
gitea-pages: $(shell find . -type f -name "*.go" ) go.mod go.sum
|
||||||
@CGO_ENABLED=0 go build -ldflags="-s -w" -o $@ .
|
@CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o $@ .
|
||||||
|
|
||||||
.PHONY: debug
|
.PHONY: debug
|
||||||
|
|
||||||
debug: gitea-pages
|
debug: gitea-pages
|
||||||
@./gitea-pages -conf config-local.yaml -debug
|
@./gitea-pages -conf config-local.yaml -debug
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
@go test -v ./...
|
@go test -v ./...
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: releases
|
||||||
|
releases:
|
||||||
|
@make release GOOS=linux GOARCH=amd64 && \
|
||||||
|
make release GOOS=linux GOARCH=arm64 && \
|
||||||
|
make release GOOS=linux GOARCH=loong64 && \
|
||||||
|
make release GOOS=windows GOARCH=amd64
|
||||||
|
|||||||
Reference in New Issue
Block a user