Compare commits

...

35 Commits

Author SHA1 Message Date
gapodo 688dee0853 full release test
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline was successful Details
2022-12-06 15:19:12 +01:00
gapodo e611b9d181 fix
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline was successful Details
2022-12-06 14:57:45 +01:00
gapodo dc8a83a8d3 quickrun
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-06 14:32:27 +01:00
gapodo 6746143b36 build...
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-06 11:50:35 +01:00
gapodo 464d02d447 build... 2022-12-06 11:49:55 +01:00
gapodo 521dd9b38c fix map script
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-06 02:42:24 +01:00
gapodo d6ca4cf0ef activate full build
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-06 00:17:16 +01:00
gapodo 96ee561f45 improved upload
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline was successful Details
2022-12-05 22:59:15 +01:00
gapodo 09590f3df5 fixed incorrect chmod 2022-12-05 22:18:33 +01:00
gapodo 60625e2d37 fix prerelease
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 22:09:17 +01:00
gapodo a2e22c25b1 debug docker 2022-12-05 22:06:06 +01:00
gapodo e40a76a158 retry
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 20:39:58 +01:00
gapodo 3c9d196803 re-add tests
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 20:06:50 +01:00
gapodo af6ce02555 without upx
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline is pending Details
ci/woodpecker/tag/release-version Pipeline is pending Details
2022-12-05 20:05:13 +01:00
gapodo a5c2f16b0f next
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 03:32:18 +01:00
gapodo 19f72ce725 f. cache
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 03:05:55 +01:00
gapodo ee72f5b15e add xzutils
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 02:52:33 +01:00
gapodo 3fd0bc95c4 another one
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 02:47:12 +01:00
gapodo 6d76151088 retry...
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 02:36:10 +01:00
gapodo af0f4bf34d speed build :D
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 02:21:57 +01:00
gapodo 6d174776dc next try...
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 01:54:28 +01:00
gapodo 7599887d44 updated build
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-05 01:36:52 +01:00
gapodo 3c68e3b642 check2
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline was successful Details
2022-12-04 23:21:19 +01:00
gapodo ba8d08110a cleanup 1
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-04 22:46:35 +01:00
gapodo 8824d29f8f changed base image
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline was successful Details
2022-12-04 21:28:30 +01:00
gapodo e2d1d29511 test
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-04 19:42:50 +01:00
gapodo 9e7bf45d42 add sqlite skip
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
2022-12-04 19:23:39 +01:00
gapodo 85f0397d97 removed debugging leftovers 2022-12-04 19:20:14 +01:00
gapodo a6ef321c9a full run prep
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-04 18:04:04 +01:00
gapodo 8eeee70a40 testrun tag
ci/woodpecker/push/compliance-and-tests Pipeline is pending Details
ci/woodpecker/push/release-version Pipeline is pending Details
ci/woodpecker/tag/compliance-and-tests Pipeline was successful Details
ci/woodpecker/tag/release-version Pipeline failed Details
2022-12-04 17:00:08 +01:00
gapodo fd310a8b74 added arm64 to docker 2022-12-04 16:41:23 +01:00
gapodo 564506bb02 fix file name
ci/woodpecker/push/compliance-and-tests Pipeline failed Details
ci/woodpecker/push/release-version unknown status Details
ci/woodpecker/manual/compliance-and-tests Pipeline was successful Details
ci/woodpecker/manual/release-version Pipeline failed Details
2022-12-04 16:15:03 +01:00
gapodo 844f1316be fixed typo 2022-12-04 16:03:06 +01:00
gapodo 1e7e975d5e next try 2022-12-04 16:02:31 +01:00
gapodo 7b92385a7d Reworked build 2022-12-04 15:50:37 +01:00
10 changed files with 472 additions and 133 deletions

1
.gitignore vendored
View File

@ -55,6 +55,7 @@ cpu.out
/bin
/dist
/docker/bin
/custom/*
!/custom/conf
/custom/conf/*

View File

@ -0,0 +1,111 @@
platform: linux/amd64
workspace:
base: /go
path: src/codeberg/gitea
variables:
- &golang_image 'golang:1.19'
- &gitea_test_env_image 'gitea/test_env:linux-amd64'
pipeline:
# dummy:
# image: *golang_image
# commands:
# - exit 0
deps-backend:
image: *golang_image
pull: true
secrets:
- goproxy_override
commands:
- test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}"
- make deps-backend
security-check:
image: *golang_image
pull: true
secrets:
- goproxy_override
commands:
- test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}"
- make security-check
lint-backend:
image: *gitea_test_env_image
pull: true
secrets:
- goproxy_override
environment:
- TAGS=bindata sqlite sqlite_unlock_notify
- GOSUMDB=sum.golang.org
commands:
- test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}"
- make lint-backend
checks-backend:
image: *golang_image
pull: true
secrets:
- goproxy_override
commands:
- test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}"
- make --always-make checks-backend
fetch-tags:
image: docker:git
pull: true
commands:
- git config --add safe.directory '*'
- git fetch --tags --force
tag-pre-condition:
image: drone/git
pull: true
commands:
- git update-ref refs/heads/tag_test ${CI_COMMIT_SHA}
prepare-test-env:
image: *gitea_test_env_image
pull: true
secrets:
- goproxy_override
commands:
- test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}"
- ./build/test-env-prepare.sh
build-test:
image: *gitea_test_env_image
pull: true
secrets:
- goproxy_override
environment:
- GOSUMDB=sum.golang.org
- TAGS=bindata sqlite sqlite_unlock_notify
commands:
- test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}"
- su gitea -c './build/test-env-check.sh'
- su gitea -c 'make backend'
unit-test:
image: *gitea_test_env_image
pull: true
secrets:
- github_read_token
- goproxy_override
environment:
- TAGS=bindata sqlite sqlite_unlock_notify
- RACE_ENABLED=true
commands:
- test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}"
- su gitea -c 'make unit-test-coverage test-check'
test-sqlite:
image: *gitea_test_env_image
environment:
- USE_REPO_TEST_DIR=1
- GOPROXY=off
- TAGS=bindata gogit sqlite sqlite_unlock_notify
- TEST_TAGS=bindata gogit sqlite sqlite_unlock_notify
commands:
- su gitea -c 'timeout -s ABRT 120m make test-sqlite-migration test-sqlite'

View File

@ -1,32 +0,0 @@
platform: linux/amd64
workspace:
base: /go
path: src/codeberg/gitea
pipeline:
deps-backend:
image: golang:1.19
pull: true
commands:
- make deps-backend
security-check:
image: golang:1.19
pull: true
commands:
- make security-check
lint-backend:
image: gitea/test_env:linux-amd64
pull: true
environment:
- TAGS=bindata sqlite sqlite_unlock_notify
- GOSUMDB=sum.golang.org
commands:
- make lint-backend
checks-backend:
image: golang:1.19
commands:
- make --always-make checks-backend

View File

@ -1,28 +0,0 @@
platform: linux/amd64
depends_on:
- testing-amd64
pipeline:
fetch-tags:
image: docker:git
pull: true
commands:
- git config --add safe.directory '*'
- git fetch --tags --force
publish:
image: woodpeckerci/plugin-docker-buildx
pull: true
settings:
platforms: linux/amd64
registry:
from_secret: domain
tag: ${CI_COMMIT_TAG##v}
repo: ${CI_REPO_LINK##https://}
password:
from_secret: releaseteamtoken
username:
from_secret: releaseteamuser
when:
event: tag

View File

@ -1,12 +1,24 @@
platform: linux/amd64
depends_on:
- testing-amd64
- compliance-and-tests
workspace:
base: /source
path: /
variables:
- &golang_image 'golang:1.19'
- &node_image 'node:18'
- &xgo_image 'techknowlogick/xgo:go-1.19.x'
- &buildx_plugin_image 'woodpeckerci/plugin-docker-buildx'
- &gpgsign_plugin_image 'plugins/gpgsign:1'
# Docker and XGO platforms may vary in name (arm/v6/v7,...), please make sure,
# that all platforms listed in docker_platforms are also in make_platforms
# for the mapping look at docker/map-binaries.sh
- &make_platforms 'linux/amd64,linux/arm64'
- &docker_platforms 'linux/amd64,linux/arm64'
pipeline:
fetch-tags:
image: docker:git
@ -16,30 +28,47 @@ pipeline:
- git fetch --tags --force
deps-frontend:
image: node:18
image: *node_image
pull: true
commands:
- make deps-frontend
deps-backend:
image: golang:1.19
image: *golang_image
pull: true
commands:
- test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}"
- make deps-backend
secrets:
- goproxy_override
static:
image: techknowlogick/xgo:go-1.19.x
build-static:
image: *xgo_image
pull: true
commands:
- test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}"
- export WS_BASE="$(pwd)"
- echo "installing nodejs"
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get -qqy install nodejs
#- echo "installing xz-utils"
#- apt-get install -qqy xz-utils
- export PATH=$PATH:$GOPATH/bin
- make CI=true LINUX_ARCHS=linux/amd64,linux/arm64 release
- echo "building forgejo"
- cd $WS_BASE
- make CI=true LINUX_ARCHS=$${LINUX_ARCHS} release
- echo "building environment-to-ini"
- cd $WS_BASE/contrib/environment-to-ini
- make CI=true LINUX_ARCHS=$${LINUX_ARCHS} release
environment:
TAGS: bindata sqlite sqlite_unlock_notify
DEBIAN_FRONTEND: noninteractive
UPXVERSION: 4.0.1
LINUX_ARCHS: *make_platforms
secrets:
- goproxy_override
gpg-sign:
image: plugins/gpgsign:1
image: *gpgsign_plugin_image
pull: true
settings:
detach_sign: true
@ -49,17 +78,58 @@ pipeline:
- "dist/release/*"
key:
from_secret: releaseteamgpg
when:
event: tag
release:
image: golang:1.19
image: *golang_image
commands:
- curl -sL https://dl.gitea.io/tea/0.9.0/tea-0.9.0-linux-amd64 > /bin/tea && chmod +x /bin/tea
- REMOTE=$(echo $CI_REPO_LINK | sed -e 's|.*://||' -e 's|/.*||')
- GITEA_SERVER_URL=$CI_REPO_LINK GITEA_SERVER_TOKEN=$RELEASETEAMTOKEN tea login add --name $RELEASETEAMUSER --url $REMOTE
- ASSETS=$(ls dist/release/* | sed -e 's/^/-a /')
- tea release create $ASSETS --tag $CI_COMMIT_TAG --title $CI_COMMIT_TAG
- echo "$${CI_COMMIT_TAG##v}" | grep -qi '\-rc' && export RELEASETYPE="--prerelease" && echo "Uploading as Pre-Release"
- echo "$${CI_COMMIT_TAG##v}" | grep -qi '\-test' && export RELEASETYPE="--draft" && echo "Uploading as Draft"
- test $${RELEASETYPE+false} || echo "Uploading as Stable"
- tea release create $ASSETS --tag $CI_COMMIT_TAG --title $CI_COMMIT_TAG $${RELEASETYPE}
when:
event: tag
secrets:
- releaseteamtoken
- releaseteamuser
prep-multiarch-binaries:
image: *golang_image # image reuse to reduce pull times, go not required we just need bash
pull: true
# the fallback version-name used by make, defaults to main in the script use this if we change the default name
# environment:
# defaulttagname: main
commands:
- ./docker/map-binaries.sh ./dist/binaries forgejo gitea ${CI_COMMIT_TAG##v}
- ./docker/map-binaries.sh ./dist/contrib environment-to-ini false ${CI_COMMIT_TAG##v}
when:
event: tag
build-docker:
image: *buildx_plugin_image
pull: true
settings:
dockerfile: Dockerfile.ci
no_cache: true
platforms: *docker_platforms
registry:
from_secret: domain
tag: ${CI_COMMIT_TAG##v}
repo: ${CI_REPO_LINK##https://}
build_args:
- CACHEBUST=${CI_PIPELINE_NUMBER}
build_args_from_env:
- CI_COMMIT_TAG
password:
from_secret: releaseteamtoken
username:
from_secret: releaseteamuser
when:
event: tag

View File

@ -1,63 +0,0 @@
platform: linux/amd64
depends_on:
- compliance
workspace:
base: /go
path: src/codeberg/gitea
pipeline:
fetch-tags:
image: docker:git
pull: true
commands:
- git config --add safe.directory '*'
- git fetch --tags --force
deps-backend:
image: golang:1.19
pull: true
commands:
- make deps-backend
tag-pre-condition:
image: drone/git
pull: true
commands:
- git update-ref refs/heads/tag_test ${CI_COMMIT_SHA}
prepare-test-env:
image: gitea/test_env:linux-amd64
pull: true
commands:
- ./build/test-env-prepare.sh
build:
image: gitea/test_env:linux-amd64
environment:
- GOSUMDB=sum.golang.org
- TAGS=bindata sqlite sqlite_unlock_notify
commands:
- su gitea -c './build/test-env-check.sh'
- su gitea -c 'make backend'
unit-test:
image: gitea/test_env:linux-amd64
environment:
- TAGS=bindata sqlite sqlite_unlock_notify
- RACE_ENABLED=true
secrets:
- github_read_token
commands:
- su gitea -c 'make unit-test-coverage test-check'
test-sqlite:
image: gitea/test_env:linux-amd64
environment:
- USE_REPO_TEST_DIR=1
- GOPROXY=off
- TAGS=bindata gogit sqlite sqlite_unlock_notify
- TEST_TAGS=bindata gogit sqlite sqlite_unlock_notify
commands:
- su gitea -c 'timeout -s ABRT 120m make test-sqlite-migration test-sqlite'

53
Dockerfile.ci Normal file
View File

@ -0,0 +1,53 @@
FROM --platform=$BUILDPLATFORM alpine:3.17.0 as prep
ARG BUILDPLATFORM
COPY docker /docker/
RUN chmod 755 /docker/root/usr/bin/entrypoint /docker/root/usr/local/bin/gitea /docker/root/etc/s6/gitea/* /docker/root/etc/s6/openssh/* /docker/root/etc/s6/.s6-svscan/*
FROM alpine:3.17.0
LABEL maintainer="contact@forgejo.org"
ARG TARGETPLATFORM
ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
EXPOSE 22 3000
#regrouped as updates to it should happen less frequently
RUN addgroup \
-S -g 1000 \
git && \
adduser \
-S -H -D \
-h /data/git \
-s /bin/bash \
-u 1000 \
-G git \
git && \
echo "git:*" | chpasswd -e
RUN apk --no-cache add \
bash \
ca-certificates \
curl \
gettext \
git \
linux-pam \
openssh \
s6 \
sqlite \
su-exec \
gnupg \
tzdata
ENV USER git
ENV GITEA_CUSTOM /data/gitea
VOLUME ["/data"]
ENTRYPOINT ["/usr/bin/entrypoint"]
CMD ["/bin/s6-svscan", "/etc/s6"]
COPY --from=prep /docker/root /
COPY --chmod=755 ./docker/bin/$TARGETPLATFORM/* /app/gitea/
RUN ln -s /app/gitea/environment-to-ini /usr/local/bin/environment-to-ini

View File

@ -0,0 +1,140 @@
ifeq ($(USE_REPO_TEST_DIR),1)
# This rule replaces the whole Makefile when we're trying to use /tmp repository temporary files
location = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
self := $(location)
%:
@tmpdir=`mktemp --tmpdir -d` ; \
echo Using temporary directory $$tmpdir for test repositories ; \
USE_REPO_TEST_DIR= $(MAKE) -f $(self) --no-print-directory REPO_TEST_DIR=$$tmpdir/ $@ ; \
STATUS=$$? ; rm -r "$$tmpdir" ; exit $$STATUS
else
# This is the "normal" part of the Makefile
DIST := ../../dist
DIST_DIRS := $(DIST)/contrib $(DIST)/contrib-release
GO ?= go
HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
COMMA := ,
XGO_VERSION := go-1.19.x
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
ifeq ($(HAS_GO), GO)
GOPATH ?= $(shell $(GO) env GOPATH)
export PATH := $(GOPATH)/bin:$(PATH)
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
endif
EXECUTABLEPREFIX := environment-to-ini
ifeq ($(shell sed --version 2>/dev/null | grep -q GNU && echo gnu),gnu)
SED_INPLACE := sed -i
else
SED_INPLACE := sed -i ''
endif
EXTRA_GOFLAGS ?=
MAKE_VERSION := $(shell "$(MAKE)" -v | head -n 1)
ifeq ($(RACE_ENABLED),true)
GOFLAGS += -race
GOTESTFLAGS += -race
endif
STORED_VERSION_FILE := VERSION
ifneq ($(DRONE_TAG),)
VERSION ?= $(subst v,,$(DRONE_TAG))
GITEA_VERSION ?= $(VERSION)
else
ifneq ($(DRONE_BRANCH),)
VERSION ?= $(shell echo $(DRONE_BRANCH) | sed -e 's|v\([0-9.][0-9.]*\)/.*|\1|')
else
VERSION ?= main
endif
STORED_VERSION=$(shell cat $(STORED_VERSION_FILE) 2>/dev/null)
ifneq ($(STORED_VERSION),)
GITEA_VERSION ?= $(STORED_VERSION)
else
GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
endif
endif
LDFLAGS := $(LDFLAGS) -s -w -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
GO_PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
TAGS ?=
TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS))
GO_DIRS := .
GO_SOURCES := $(wildcard *.go)
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go")
.PHONY: go-check
go-check:
$(eval MIN_GO_VERSION_STR := $(shell grep -Eo '^go\s+[0-9]+\.[0-9]+' go.mod | cut -d' ' -f2))
$(eval MIN_GO_VERSION := $(shell printf "%03d%03d" $(shell echo '$(MIN_GO_VERSION_STR)' | tr '.' ' ')))
$(eval GO_VERSION := $(shell printf "%03d%03d" $(shell $(GO) version | grep -Eo '[0-9]+\.[0-9]+' | tr '.' ' ');))
@if [ "$(GO_VERSION)" -lt "$(MIN_GO_VERSION)" ]; then \
echo "Gitea requires Go $(MIN_GO_VERSION_STR) or greater to build. You can get it at https://go.dev/dl/"; \
exit 1; \
fi
.PHONY: clean
clean:
$(GO) clean -i ./...
rm -rf $(DIST)
.PHONY: generate
generate: $(TAGS_PREREQ) generate-go
.PHONY: generate-go
generate-go: $(TAGS_PREREQ)
@echo "Running go generate..."
@CC= GOOS= GOARCH= $(GO) generate -tags '$(TAGS)' $(GO_PACKAGES)
.PHONY: release
release: generate release-linux release-copy
$(DIST_DIRS):
mkdir -p $(DIST_DIRS)
.PHONY: release-windows
release-windows: | $(DIST_DIRS)
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/contrib -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets 'windows/*' -out $(EXECUTABLEPREFIX)-$(VERSION) .
ifeq ($(CI),true)
cp /build/$(EXECUTABLEPREFIX)-* $(DIST)/contrib
endif
.PHONY: release-linux
release-linux: | $(DIST_DIRS)
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/contrib -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out $(EXECUTABLEPREFIX)-$(VERSION) .
ifeq ($(CI),true)
cp /build/$(EXECUTABLEPREFIX)-* $(DIST)/contrib
endif
.PHONY: release-darwin
release-darwin: | $(DIST_DIRS)
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/contrib -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'darwin-10.12/amd64,darwin-10.12/arm64' -out $(EXECUTABLEPREFIX)-$(VERSION) .
ifeq ($(CI),true)
cp /build/$(EXECUTABLEPREFIX)-* $(DIST)/contrib
endif
.PHONY: release-copy
release-copy: | $(DIST_DIRS)
cd $(DIST); for file in `find ./contrib -type f -name "$(EXECUTABLEPREFIX)-*"`; do cp $${file} ./contrib-release/; done;
# This endif closes the if at the top of the file
endif

9
docker/archmap.txt Normal file
View File

@ -0,0 +1,9 @@
# file-name-suffix:docker platform
# quick lookups: https://github.com/techknowlogick/xgo and https://github.com/BretFisher/multi-platform-docker-build#know-what-platforms-you-can-build-in-your-docker-engine
linux-amd64:linux/amd64
linux-386:linux/386
linux-arm-6:linux/arm/v6
linux-arm-7:linux/arm/v7
linux-arm64:linux/arm64
linux-riscv64:linux/riscv64
# add mappings for more platforms below

78
docker/map-binaries.sh Executable file
View File

@ -0,0 +1,78 @@
#!/bin/bash
errcho () {
echo "${@}" >&2
}
if [ ${#@} -lt 3 ]; then
errcho "not enough arguments provided"
echo "syntax: ${0} <path directly containing the binary> <base name of the binary> <target name or false> [<version tag as in the file name>]"
exit 2
fi
BINARYLOOKUPPATH="${1}"
FILEBASENAME="${2}"
RENAME="${3}"
if [ ${#@} -gt 3 ] && ! [ "${4}" == "" ]; then
echo "Tag provided: ${4}"
FILEVERSION="${4}"
else
echo "No tag provided defaulting to tag ${DEFAULTTAGNAME:-main}"
FILEVERSION="${DEFAULTTAGNAME:-main}"
fi
OUTFILENAME=""
if [ "${RENAME}" == "false" ]; then
echo "Rename deactivated outputting as ${FILEBASENAME}"
OUTFILENAME="${FILEBASENAME}"
elif [ "${RENAME}" == "true" ]; then
OUTFILENAME="gitea"
echo "Rename set to true, renaming to ${OUTFILENAME}"
else
echo "Rename target name provided, renaming to ${RENAME}"
OUTFILENAME="${RENAME}"
fi
FILE_WIHTOUT_PLATFORM="${FILEBASENAME}-${FILEVERSION}"
DOCKERDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit 3; pwd -P )"
WS_BASE="${DOCKERDIR%/docker}"
if [ ! -f "${DOCKERDIR}/archmap.txt" ]; then
errcho "no archmap found"
exit 4
fi
if [ ! -d "${DOCKERDIR}/bin" ]; then
echo "Folder ${DOCKERDIR}/bin missing, creating it"
mkdir -p "${DOCKERDIR}/bin"
fi
map () {
local file="${1}"
local bin_platform="${file##"./${FILE_WIHTOUT_PLATFORM}-"}"
local platform
echo "handling ${file} with detected bin_platform $bin_platform"
if ! grep -q "$bin_platform" "${DOCKERDIR}/archmap.txt"; then
errcho "no matching platform for $file found"
return 0
fi
platform="$(grep "$bin_platform" "${DOCKERDIR}/archmap.txt" | cut -d':' -f2)"
echo "Docker platform parsed: $platform"
if [ ! -d "${DOCKERDIR}/bin/$platform" ]; then
echo "First item for this platform, creating directory \"${DOCKERDIR}/bin/$platform\""
mkdir -p "${DOCKERDIR}/bin/$platform"
fi
echo "Mapped ${file} to $platform, copying to \"${DOCKERDIR}/bin/$platform/${OUTFILENAME}\""
cp "${file}" "${DOCKERDIR}/bin/$platform/${OUTFILENAME}"
}
cd "$WS_BASE/${BINARYLOOKUPPATH}" || exit 5
while IFS= read -r -d $'\0' infile; do
map "$infile"
done < <(find . -maxdepth 1 -type f -name "${FILE_WIHTOUT_PLATFORM}-*" -print0)
cd "$WS_BASE"