Compare commits
No commits in common. "ci-optimization" and "forgejo" have entirely different histories.
ci-optimiz
...
forgejo
10 changed files with 133 additions and 472 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -55,7 +55,6 @@ cpu.out
|
||||||
|
|
||||||
/bin
|
/bin
|
||||||
/dist
|
/dist
|
||||||
/docker/bin
|
|
||||||
/custom/*
|
/custom/*
|
||||||
!/custom/conf
|
!/custom/conf
|
||||||
/custom/conf/*
|
/custom/conf/*
|
||||||
|
|
|
@ -1,111 +0,0 @@
|
||||||
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'
|
|
32
.woodpecker/compliance.yml
Normal file
32
.woodpecker/compliance.yml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
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
|
28
.woodpecker/docker-linux-amd64-release-version.yml
Normal file
28
.woodpecker/docker-linux-amd64-release-version.yml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
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
|
|
@ -1,24 +1,12 @@
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- compliance-and-tests
|
- testing-amd64
|
||||||
|
|
||||||
workspace:
|
workspace:
|
||||||
base: /source
|
base: /source
|
||||||
path: /
|
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:
|
pipeline:
|
||||||
fetch-tags:
|
fetch-tags:
|
||||||
image: docker:git
|
image: docker:git
|
||||||
|
@ -28,47 +16,30 @@ pipeline:
|
||||||
- git fetch --tags --force
|
- git fetch --tags --force
|
||||||
|
|
||||||
deps-frontend:
|
deps-frontend:
|
||||||
image: *node_image
|
image: node:18
|
||||||
pull: true
|
pull: true
|
||||||
commands:
|
commands:
|
||||||
- make deps-frontend
|
- make deps-frontend
|
||||||
|
|
||||||
deps-backend:
|
deps-backend:
|
||||||
image: *golang_image
|
image: golang:1.19
|
||||||
pull: true
|
pull: true
|
||||||
commands:
|
commands:
|
||||||
- test "$${GOPROXY_OVERRIDE-}" != "" && export GOPROXY="$${GOPROXY_OVERRIDE}"
|
- make deps-backend
|
||||||
- make deps-backend
|
|
||||||
secrets:
|
|
||||||
- goproxy_override
|
|
||||||
|
|
||||||
build-static:
|
static:
|
||||||
image: *xgo_image
|
image: techknowlogick/xgo:go-1.19.x
|
||||||
pull: true
|
pull: true
|
||||||
commands:
|
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
|
- 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
|
- export PATH=$PATH:$GOPATH/bin
|
||||||
- echo "building forgejo"
|
- make CI=true LINUX_ARCHS=linux/amd64,linux/arm64 release
|
||||||
- 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:
|
environment:
|
||||||
TAGS: bindata sqlite sqlite_unlock_notify
|
TAGS: bindata sqlite sqlite_unlock_notify
|
||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: noninteractive
|
||||||
UPXVERSION: 4.0.1
|
|
||||||
LINUX_ARCHS: *make_platforms
|
|
||||||
secrets:
|
|
||||||
- goproxy_override
|
|
||||||
|
|
||||||
gpg-sign:
|
gpg-sign:
|
||||||
image: *gpgsign_plugin_image
|
image: plugins/gpgsign:1
|
||||||
pull: true
|
pull: true
|
||||||
settings:
|
settings:
|
||||||
detach_sign: true
|
detach_sign: true
|
||||||
|
@ -78,58 +49,17 @@ pipeline:
|
||||||
- "dist/release/*"
|
- "dist/release/*"
|
||||||
key:
|
key:
|
||||||
from_secret: releaseteamgpg
|
from_secret: releaseteamgpg
|
||||||
when:
|
|
||||||
event: tag
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
image: *golang_image
|
image: golang:1.19
|
||||||
commands:
|
commands:
|
||||||
- curl -sL https://dl.gitea.io/tea/0.9.0/tea-0.9.0-linux-amd64 > /bin/tea && chmod +x /bin/tea
|
- 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|/.*||')
|
- 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
|
- 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 /')
|
- ASSETS=$(ls dist/release/* | sed -e 's/^/-a /')
|
||||||
- echo "$${CI_COMMIT_TAG##v}" | grep -qi '\-rc' && export RELEASETYPE="--prerelease" && echo "Uploading as Pre-Release"
|
- tea release create $ASSETS --tag $CI_COMMIT_TAG --title $CI_COMMIT_TAG
|
||||||
- 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:
|
when:
|
||||||
event: tag
|
event: tag
|
||||||
secrets:
|
secrets:
|
||||||
- releaseteamtoken
|
- releaseteamtoken
|
||||||
- releaseteamuser
|
- 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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
63
.woodpecker/testing-amd64.yml
Normal file
63
.woodpecker/testing-amd64.yml
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
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'
|
|
@ -1,53 +0,0 @@
|
||||||
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
|
|
|
@ -1,140 +0,0 @@
|
||||||
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
|
|
|
@ -1,9 +0,0 @@
|
||||||
# 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
|
|
|
@ -1,78 +0,0 @@
|
||||||
#!/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"
|
|
Loading…
Add table
Reference in a new issue