1
0
Эх сурвалжийг харах

WIP: Pack release archives using Docker

Joe Chen 3 жил өмнө
parent
commit
b9266247a4

+ 5 - 3
.dockerignore

@@ -1,10 +1,7 @@
 .packager
 .packager/**
-scripts
-scripts/**
 .github/
 .github/**
-config.codekit
 .dockerignore
 *.yml
 *.md
@@ -12,3 +9,8 @@ config.codekit
 .gitignore
 Dockerfile*
 gogs
+.task
+
+!Taskfile.yml
+!README.md
+!README_ZH.md

+ 35 - 0
docs/dev/release/linux-386.Dockerfile

@@ -0,0 +1,35 @@
+# CentOS 7 comes with GLIBC 2.17 which is the most compatible (the lowest)
+# version available in a not-too-oudated Linux distribution.
+FROM centos:7
+RUN yum install --quiet --assumeyes git wget gcc pam-devel zip
+
+# Install Go
+RUN wget --quiet https://go.dev/dl/go1.17.7.linux-386.tar.gz -O go.linux-386.tar.gz
+RUN sh -c 'echo "5d5472672a2e0252fe31f4ec30583d9f2b320f9b9296eda430f03cbc848400ce go.linux-386.tar.gz" | sha256sum --check --status'
+RUN tar -C /usr/local -xzf go.linux-386.tar.gz
+ENV PATH="/usr/local/go/bin:${PATH}"
+
+# Install Task
+RUN wget --quiet https://github.com/go-task/task/releases/download/v3.10.0/task_linux_386.tar.gz -O task_linux_386.tar.gz
+# RUN sh -c 'echo "90bb2d757f5bf621cf0e7fa24a5da8723025b8a862e3939ce74a888ad8ce1722 task_linux_386.tar.gz" | sha256sum --check --status'
+RUN tar -xzf task_linux_386.tar.gz \
+  && mv task /usr/local/bin/task
+
+# THIS IS NOT WORKING
+# Build bianry (using raw commands because Task release binary for Linux 386 is not running within container)
+WORKDIR /gogs.io/gogs
+COPY . .
+RUN go build -v \
+  -ldflags " \
+    -X 'gogs.io/gogs/internal/conf.BuildTime=$(date -u "+%Y-%m-%d %I:%M:%S %Z")' \
+    -X 'gogs.io/gogs/internal/conf.BuildCommit=$(git rev-parse HEAD)' \
+  " \
+  -tags 'cert pam' \
+  -trimpath -o gogs
+
+# Pack release archives
+RUN rm -rf release \
+  mkdir -p release/gogs \
+  cp -r gogs LICENSE README.md README_ZH.md scripts release/gogs \
+  cd release && zip -r gogs.zip gogs
+RUN tar -czf gogs.tar.gz gogs

+ 25 - 0
docs/dev/release/linux-amd64.Dockerfile

@@ -0,0 +1,25 @@
+# CentOS 7 comes with GLIBC 2.17 which is the most compatible (the lowest)
+# version available in a not-too-oudated Linux distribution.
+FROM centos:7
+RUN yum install --quiet --assumeyes git wget gcc pam-devel zip
+
+# Install Go
+RUN wget --quiet https://go.dev/dl/go1.17.7.linux-amd64.tar.gz -O go.linux-amd64.tar.gz
+RUN sh -c 'echo "02b111284bedbfa35a7e5b74a06082d18632eff824fd144312f6063943d49259 go.linux-amd64.tar.gz" | sha256sum --check --status'
+RUN tar -C /usr/local -xzf go.linux-amd64.tar.gz
+ENV PATH="/usr/local/go/bin:${PATH}"
+
+# Install Task
+RUN wget --quiet https://github.com/go-task/task/releases/download/v3.10.0/task_linux_amd64.tar.gz -O task_linux_amd64.tar.gz
+RUN sh -c 'echo "f78c861e6c772a3263e478da7ae3223e10c2bc6b7b0728717d30db35d463f4b9 task_linux_amd64.tar.gz" | sha256sum --check --status'
+RUN tar -xzf task_linux_amd64.tar.gz \
+  && mv task /usr/local/bin/task
+
+# Build bianry
+WORKDIR /gogs.io/gogs
+COPY . .
+RUN TAGS="cert pam" task build
+
+# Pack release archives
+RUN task release
+RUN tar -C release -czf release/gogs.tar.gz gogs

+ 21 - 6
docs/dev/release/release_new_version.md

@@ -5,6 +5,14 @@
 
 ## Playbooks
 
+### Prerequisite
+
+Install Docker Buildx:
+
+```sh
+$ docker buildx install
+```
+
 ### Update Docker image tag
 
 1. Pull down images and create a manifest:
@@ -47,14 +55,21 @@ All commands are starting at the repository root.
 	# Produce the ZIP archive
 	$ TAGS=cert task release
 	```
-- Linux:
+- Linux AMD64 and i386:
 	```sh
-	# Produce the ZIP archive
-	$ TAGS="cert pam" task release
-
-	# Produce the Tarball
     $ export VERSION=0.12.4
-	$ cd release && tar czf gogs_${VERSION}_linux_$(go env GOARCH).tar.gz gogs
+
+	$ docker pull --platform linux/amd64 centos:7
+	$ docker buildx build --no-cache --platform=linux/amd64 -f docs/dev/release/linux-amd64.Dockerfile .
+	$ docker run --name=gogs_${VERSION}_linux_amd64 --platform=linux/amd64 <image SHA>
+	$ docker cp gogs_${VERSION}_linux_amd64:/gogs.io/gogs/release/gogs.zip gogs_${VERSION}_linux_amd64.zip
+	$ docker cp gogs_${VERSION}_linux_amd64:/gogs.io/gogs/release/gogs.tar.gz gogs_${VERSION}_linux_amd64.tar.gz
+
+	$ docker pull --platform linux/386 centos:7
+	$ docker buildx build --no-cache --platform=linux/386 -f docs/dev/release/linux-386.Dockerfile .
+	$ docker run --name=gogs_${VERSION}_linux_386 --platform=linux/386 <image SHA>
+	$ docker cp gogs_${VERSION}_linux_386:/gogs.io/gogs/release/gogs.zip gogs_${VERSION}_linux_386.zip
+	$ docker cp gogs_${VERSION}_linux_386:/gogs.io/gogs/release/gogs.tar.gz gogs_${VERSION}_linux_386.tar.gz
 	```
 - ARMv7:
 	```sh