From 35d0ae9ae62e73958aaac6107c73756ff58a34f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=9D=B0=E6=9D=BE?= Date: Sat, 9 May 2020 02:41:41 +0800 Subject: [PATCH] Create main.yml --- .github/workflows/main.yml | 76 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..06010d8 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,76 @@ +name: Cloudreve-CI + +on: + push: + branches: + - master + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + + - name: 检出代码 + uses: actions/checkout@v2 + with: + ref: master + + - name: 安装go + uses: actions/setup-go@v2-beta + with: + go-version: '1.14' + - run: go version + + - name: 安装node + uses: actions/setup-node@v1 + with: + node-version: '10.x' + - run: node -v + - run: npm -v + + - name: 安装Yarn + run: | + npm install yarn -g + - run: yarn -v + + - name: 构建静态资源 + run: | + git clone https://github.com/cloudreve/frontend.git assets + cd assets + yarn install + CI=false yarn run build + cd ../ + + - name: 打包静态资源 + uses: actions/upload-artifact@master + with: + name: statics.zip + path: ./assets/build/ + + - name: 嵌入静态资源 + run: | + go get github.com/rakyll/statik + ~/statik -src=./assets/build/ -include=*.html,*.js,*.json,*.css,*.png,*.svg,*.ico -f + + - name: 设置编译环境 + run: | + export COMMIT_SHA=$(git rev-parse --short HEAD) + export VERSION=$(git describe --tags) + export CGO_ENABLED=1 + + #x86_amd64 + - name: 编译linux_amd64 + run: | + export GOARCH=amd64 + export GOOS=linux + go build -a -o ./bin/cloudreve_$VERSION_$GOOS_$GOARCH -ldflags " -X 'github.com/HFO4/cloudreve/pkg/conf.BackendVersion=$VERSION' -X 'github.com/HFO4/cloudreve/pkg/conf.LastCommit=$COMMIT_SHA'" + + + - name: 打包二进制文件 + uses: actions/upload-artifact@master + with: + name: build.zip + path: ./bin/