chore: remove statik

pull/1107/head
Ink33 4 years ago
parent 24fdeff599
commit 7d3bc3f0f1
No known key found for this signature in database
GPG Key ID: 5D8B1D036EFB0D2E

@ -9,53 +9,49 @@ jobs:
name: Build name: Build
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
steps: steps:
- name: Set up Go 1.17
- name: Set up Golang uses: actions/setup-go@v2
uses: actions/setup-go@v1 with:
with: go-version: "1.17"
go-version: 1.17 id: go
id: go
- name: Check out code into the Go module directory
- name: Check out code into the Go module directory uses: actions/checkout@v2
uses: actions/checkout@v2 with:
with: clean: false
clean: false submodules: "recursive"
submodules: 'recursive' - run: |
- run: | git fetch --prune --unshallow --tags
git fetch --prune --unshallow --tags
- name: Get dependencies and build
- name: Get dependencies and build run: |
run: | sudo apt-get update
go install github.com/rakyll/statik sudo apt-get -y install gcc-mingw-w64-x86-64
export PATH=$PATH:~/go/bin/ sudo apt-get -y install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
statik -src=models -f sudo apt-get -y install gcc-aarch64-linux-gnu libc6-dev-arm64-cross
sudo apt-get update chmod +x ./build.sh
sudo apt-get -y install gcc-mingw-w64-x86-64 ./build.sh -r b
sudo apt-get -y install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
sudo apt-get -y install gcc-aarch64-linux-gnu libc6-dev-arm64-cross - name: Upload binary files (windows_amd64)
chmod +x ./build.sh uses: actions/upload-artifact@v2
./build.sh -r b with:
name: cloudreve_windows_amd64
- name: Upload binary files (windows_amd64) path: release/cloudreve*windows_amd64.*
uses: actions/upload-artifact@v2
with: - name: Upload binary files (linux_amd64)
name: cloudreve_windows_amd64 uses: actions/upload-artifact@v2
path: release/cloudreve*windows_amd64.* with:
name: cloudreve_linux_amd64
- name: Upload binary files (linux_amd64) path: release/cloudreve*linux_amd64.*
uses: actions/upload-artifact@v2
with: - name: Upload binary files (linux_arm)
name: cloudreve_linux_amd64 uses: actions/upload-artifact@v2
path: release/cloudreve*linux_amd64.* with:
name: cloudreve_linux_arm
- name: Upload binary files (linux_arm) path: release/cloudreve*linux_arm.*
uses: actions/upload-artifact@v2
with: - name: Upload binary files (linux_arm64)
name: cloudreve_linux_arm uses: actions/upload-artifact@v2
path: release/cloudreve*linux_arm.* with:
name: cloudreve_linux_arm64
- name: Upload binary files (linux_arm64) path: release/cloudreve*linux_arm64.*
uses: actions/upload-artifact@v2
with:
name: cloudreve_linux_arm64
path: release/cloudreve*linux_arm64.*

@ -27,8 +27,9 @@ jobs:
- name: Build static files - name: Build static files
run: | run: |
cd assets cd assets
yarn install mkdir build
yarn run build cd build
touch test.html
- name: Test - name: Test
run: go test -coverprofile=coverage.txt -covermode=atomic ./... run: go test -coverprofile=coverage.txt -covermode=atomic ./...

@ -4,10 +4,11 @@ go:
node_js: "12.16.3" node_js: "12.16.3"
git: git:
depth: 1 depth: 1
install:
- go get github.com/rakyll/statik
before_script: before_script:
- statik -src=models -f - cd assets
- mkdir build
- cd mkdir
- touch test.html
script: script:
- go test -coverprofile=coverage.txt -covermode=atomic ./... - go test -coverprofile=coverage.txt -covermode=atomic ./...
after_success: after_success:
@ -27,4 +28,4 @@ deploy:
draft: true draft: true
skip_cleanup: true skip_cleanup: true
on: on:
tags: true tags: true

@ -28,8 +28,6 @@ RUN set -ex \
&& apk add gcc libc-dev git \ && apk add gcc libc-dev git \
&& export COMMIT_SHA=$(git rev-parse --short HEAD) \ && export COMMIT_SHA=$(git rev-parse --short HEAD) \
&& export VERSION=$(git describe --tags) \ && export VERSION=$(git describe --tags) \
&& (cd && go get github.com/rakyll/statik) \
&& statik -src=assets/build/ -include=*.html,*.js,*.json,*.css,*.png,*.svg,*.ico -f \
&& go install -ldflags "-X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.BackendVersion=${VERSION}' \ && go install -ldflags "-X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.BackendVersion=${VERSION}' \
-X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.LastCommit=${COMMIT_SHA}'\ -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.LastCommit=${COMMIT_SHA}'\
-w -s" -w -s"

@ -68,7 +68,7 @@ chmod +x ./cloudreve
## :gear: 构建 ## :gear: 构建
自行构建前需要拥有 `Go >= 1.16`、`yarn`等必要依赖。 自行构建前需要拥有 `Go >= 1.17`、`yarn`等必要依赖。
#### 克隆代码 #### 克隆代码

@ -1,13 +1,16 @@
#!/bin/bash #!/bin/bash
REPO=$(cd $(dirname $0); pwd) REPO=$(
cd $(dirname $0)
pwd
)
COMMIT_SHA=$(git rev-parse --short HEAD) COMMIT_SHA=$(git rev-parse --short HEAD)
VERSION=$(git describe --tags) VERSION=$(git describe --tags)
ASSETS="false" ASSETS="false"
BINARY="false" BINARY="false"
RELEASE="false" RELEASE="false"
debugInfo () { debugInfo() {
echo "Repo: $REPO" echo "Repo: $REPO"
echo "Build assets: $ASSETS" echo "Build assets: $ASSETS"
echo "Build binary: $BINARY" echo "Build binary: $BINARY"
@ -16,105 +19,99 @@ debugInfo () {
echo "Commit: $COMMIT_SHA" echo "Commit: $COMMIT_SHA"
} }
buildAssets () { buildAssets() {
cd $REPO cd $REPO
rm -rf assets/build rm -rf assets/build
rm -f statik/statik.go
export CI=false export CI=false
cd $REPO/assets cd $REPO/assets
yarn --update-checksums
yarn install yarn install
yarn run build yarn run build
cd build
if ! [ -x "$(command -v statik)" ]; then rm -rf *.map
export CGO_ENABLED=0
go get github.com/rakyll/statik
fi
cd $REPO
statik -src=assets/build/ -include=*.html,*.js,*.json,*.css,*.png,*.svg,*.ico,*.ttf -f
} }
buildBinary () { buildBinary() {
cd $REPO cd $REPO
go build -a -o cloudreve -ldflags " -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.BackendVersion=$VERSION' -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.LastCommit=$COMMIT_SHA'" go build -a -o cloudreve -ldflags " -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.BackendVersion=$VERSION' -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.LastCommit=$COMMIT_SHA'"
} }
_build() { _build() {
local osarch=$1 local osarch=$1
IFS=/ read -r -a arr <<<"$osarch" IFS=/ read -r -a arr <<<"$osarch"
os="${arr[0]}" os="${arr[0]}"
arch="${arr[1]}" arch="${arr[1]}"
gcc="${arr[2]}" gcc="${arr[2]}"
# Go build to build the binary. # Go build to build the binary.
export GOOS=$os export GOOS=$os
export GOARCH=$arch export GOARCH=$arch
export CC=$gcc export CC=$gcc
export CGO_ENABLED=1 export CGO_ENABLED=1
if [ -n "$VERSION" ]; then if [ -n "$VERSION" ]; then
out="release/cloudreve_${VERSION}_${os}_${arch}" out="release/cloudreve_${VERSION}_${os}_${arch}"
else else
out="release/cloudreve_${COMMIT_SHA}_${os}_${arch}" out="release/cloudreve_${COMMIT_SHA}_${os}_${arch}"
fi fi
go build -a -o "${out}" -ldflags " -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.BackendVersion=$VERSION' -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.LastCommit=$COMMIT_SHA'" go build -a -o "${out}" -ldflags " -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.BackendVersion=$VERSION' -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.LastCommit=$COMMIT_SHA'"
if [ "$os" = "windows" ]; then if [ "$os" = "windows" ]; then
mv $out release/cloudreve.exe mv $out release/cloudreve.exe
zip -j -q "${out}.zip" release/cloudreve.exe zip -j -q "${out}.zip" release/cloudreve.exe
rm -f "release/cloudreve.exe" rm -f "release/cloudreve.exe"
else else
mv $out release/cloudreve mv $out release/cloudreve
tar -zcvf "${out}.tar.gz" -C release cloudreve tar -zcvf "${out}.tar.gz" -C release cloudreve
rm -f "release/cloudreve" rm -f "release/cloudreve"
fi fi
} }
release(){ release() {
cd $REPO cd $REPO
## List of architectures and OS to test coss compilation. ## List of architectures and OS to test coss compilation.
SUPPORTED_OSARCH="linux/amd64/gcc linux/arm/arm-linux-gnueabihf-gcc windows/amd64/x86_64-w64-mingw32-gcc linux/arm64/aarch64-linux-gnu-gcc" SUPPORTED_OSARCH="linux/amd64/gcc linux/arm/arm-linux-gnueabihf-gcc windows/amd64/x86_64-w64-mingw32-gcc linux/arm64/aarch64-linux-gnu-gcc"
echo "Release builds for OS/Arch/CC: ${SUPPORTED_OSARCH}" echo "Release builds for OS/Arch/CC: ${SUPPORTED_OSARCH}"
for each_osarch in ${SUPPORTED_OSARCH}; do for each_osarch in ${SUPPORTED_OSARCH}; do
_build "${each_osarch}" _build "${each_osarch}"
done done
} }
usage() { usage() {
echo "Usage: $0 [-a] [-c] [-b] [-r]" 1>&2; echo "Usage: $0 [-a] [-c] [-b] [-r]" 1>&2
exit 1; exit 1
} }
while getopts "bacr:d" o; do while getopts "bacr:d" o; do
case "${o}" in case "${o}" in
b) b)
ASSETS="true" ASSETS="true"
BINARY="true" BINARY="true"
;; ;;
a) a)
ASSETS="true" ASSETS="true"
;; ;;
c) c)
BINARY="true" BINARY="true"
;; ;;
r) r)
ASSETS="true" ASSETS="true"
RELEASE="true" RELEASE="true"
;; ;;
d) d)
DEBUG="true" DEBUG="true"
;; ;;
*) *)
usage usage
;; ;;
esac esac
done done
shift $((OPTIND-1)) shift $((OPTIND - 1))
if [ "$DEBUG" = "true" ]; then if [ "$DEBUG" = "true" ]; then
debugInfo debugInfo

Loading…
Cancel
Save