From 30a34287940ed85cf9fce7a73314368047d2141d Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 24 Jan 2022 01:36:58 +0800 Subject: [PATCH] CD - DEBUG --- .github/workflows/build.yml | 78 +++++++++++++++++++++++++++++++++++++ Makefile | 60 +++++++++++++++++++++------- release.sh | 2 +- 3 files changed, 125 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..c1cb912b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,78 @@ +name: Build + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + unit-test: + runs-on: ubuntu-latest + strategy: + matrix: + go: [1.17] + steps: + - name: Setup Cache + uses: actions/cache@v2 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Checkout Kun + uses: actions/checkout@v2 + with: + repository: yaoapp/kun + path: kun + + - name: Checkout Xun + uses: actions/checkout@v2 + with: + repository: yaoapp/xun + path: xun + + - name: Checkout Gou + uses: actions/checkout@v2 + with: + repository: yaoapp/gou + path: gou + token: ${{ secrets.TOKEN }} + + - name: Checkout UI + uses: actions/checkout@v2 + with: + repository: yaoapp/xiang-ui + path: ui + token: ${{ secrets.TOKEN }} + + - name: Move Kun, Xun, Gou, UI + run: | + mv kun ../ + mv xun ../ + mv gou ../ + mv ui ../ + ls -l . + ls -l ../ + + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Setup Go ${{ matrix.go }} + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go }} + + - name: Setup Go Tools + run: | + if [[ "${GO111MODULE}" = "on" ]]; then go mod download; fi + if [[ "${GO111MODULE}" = "on" ]]; then export PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; fi + if [[ "${GO111MODULE}" = "on" ]]; then make tools; fi + + - name: Make Artifact + run: | + ls -l . + ls -l ../ diff --git a/Makefile b/Makefile index a677e795..3c43c914 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ plugin-mac: # 编译静态文件 .PHONY: static static: - git clone https://github.com/YaoApp/xiang-saas-ui-kxy .tmp/ui + git clone git@github.com:YaoApp/xiang-saas-ui-kxy .tmp/ui cd .tmp/ui && yarn install && yarn build rm -rf ui mv .tmp/ui/dist ui @@ -143,13 +143,13 @@ xiang: bindata .PHONY: release release: clean mkdir -p dist/release - git clone https://github.com/YaoApp/xiang dist/release - git clone https://github.com/YaoApp/kun dist/kun - git clone https://github.com/YaoApp/xun dist/xun - git clone https://github.com/YaoApp/gou dist/gou + git clone git@github.com:YaoApp/xiang.git dist/release + git clone git@github.com:YaoApp/kun.git dist/kun + git clone git@github.com:YaoApp/xun.git dist/xun + git clone git@github.com:YaoApp/gou.git dist/gou # UI制品 - git clone https://github.com/YaoApp/xiang-ui .tmp/ui + git clone git@github.com:YaoApp/xiang-ui .tmp/ui sed -ie "s/url('\/icon/url('\/xiang\/icon/g" .tmp/ui/public/icon/md_icon.css cd .tmp/ui && cnpm install && npm run build rm -rf dist/release/ui @@ -169,11 +169,11 @@ release: clean sed "s/*.iqka.com/$(XIANG_DOMAIN)/g" dist/release/share/const.go.bak > dist/release/share/const.go; \ fi; - cd dist/release && CGO_ENABLED=1 CC=x86_64-linux-musl-gcc CGO_LDFLAGS="-static" GOOS=linux GOARCH=amd64 go build -v -o ../../.tmp/xiang-${VERSION}-linux-amd64 +# cd dist/release && CGO_ENABLED=1 CC=x86_64-linux-musl-gcc CGO_LDFLAGS="-static" GOOS=linux GOARCH=amd64 go build -v -o ../../.tmp/xiang-${VERSION}-linux-amd64 # cd dist/release && GOOS=linux GOARCH=arm GOARM=7 go build -v -o ../../.tmp/xiang-${VERSION}-linux-arm # cd dist/release && GOOS=linux GOARCH=arm64 GOARM=7 go build -v -o ../../.tmp/xiang-${VERSION}-linux-arm64 - cd dist/release && GOOS=darwin GOARCH=amd64 go build -v -o ../../.tmp/xiang-${VERSION}-darwin-amd64 - cd dist/release && GOOS=windows GOARCH=386 go build -v -o ../../.tmp/xiang-${VERSION}-windows-386 + cd dist/release && CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -v -o ../../.tmp/xiang-${VERSION}-darwin-amd64 +# cd dist/release && GOOS=windows GOARCH=386 go build -v -o ../../.tmp/xiang-${VERSION}-windows-386 rm -rf dist/release mkdir -p dist/release @@ -187,13 +187,13 @@ hi: .PHONY: arm arm: clean mkdir -p dist/release - git clone https://github.com/YaoApp/xiang dist/release - git clone https://github.com/YaoApp/kun dist/kun - git clone https://github.com/YaoApp/xun dist/xun - git clone https://github.com/YaoApp/gou dist/gou + git clone git@github.com:YaoApp/xiang.git dist/release + git clone git@github.com:YaoApp/kun.git dist/kun + git clone git@github.com:YaoApp/xun.git dist/xun + git clone git@github.com:YaoApp/gou.git dist/gou # UI制品 - git clone https://github.com/YaoApp/xiang-ui .tmp/ui + git clone git@github.com:YaoApp/xiang-ui.git .tmp/ui sed -ie "s/url('\/icon/url('\/xiang\/icon/g" .tmp/ui/public/icon/md_icon.css cd .tmp/ui && cnpm install && npm run build rm -rf dist/release/ui @@ -216,6 +216,38 @@ arm: clean mv .tmp/xiang-*-* dist/release/ chmod +x dist/release/xiang-*-* +.PHONY: linux +linux: clean + mkdir -p dist/release + git clone git@github.com:YaoApp/xiang.git dist/release + git clone git@github.com:YaoApp/kun.git dist/kun + git clone git@github.com:YaoApp/xun.git dist/xun + git clone git@github.com:YaoApp/gou.git dist/gou + +# UI制品 + git clone git@github.com:YaoApp/xiang-ui.git .tmp/ui + sed -ie "s/url('\/icon/url('\/xiang\/icon/g" .tmp/ui/public/icon/md_icon.css + cd .tmp/ui && cnpm install && npm run build + rm -rf dist/release/ui + mv .tmp/ui/dist dist/release/ui + +# 静态文件打包 + mkdir -p .tmp/data + cp -r dist/release/ui .tmp/data/ + cp -r dist/release/xiang .tmp/data/ + go-bindata -fs -pkg data -o dist/release/data/bindata.go -prefix ".tmp/data/" .tmp/data/... + rm -rf .tmp/data + rm -rf .tmp/ui + +# 制品 + mkdir -p dist + cd dist/release && CGO_ENABLED=1 CGO_LDFLAGS="-static" GOOS=linux GOARCH=amd64 go build -v -o ../../.tmp/xiang-${VERSION}-linux-amd64 + + rm -rf dist/release + mkdir -p dist/release + mv .tmp/xiang-*-* dist/release/ + chmod +x dist/release/xiang-*-* + .PHONY: win32 win32: bindata GOOS=windows GOARCH=386 go build -v -o .tmp/xiang-windows-386 diff --git a/release.sh b/release.sh index 3c832cd3..1096447f 100755 --- a/release.sh +++ b/release.sh @@ -15,7 +15,7 @@ ssh max@demo-crm.iqka.com mkdir -p /data/demo-crm/ui/releases/$VERSION/ ssh max@demo-crm.iqka.com "echo {\\\"version\\\":\\\"$VERSION\\\"} > /data/demo-crm/ui/releases/latest.json" scp ~/Code/bin/xiang-$VERSION-linux-amd64 max@demo-crm.iqka.com:/data/demo-crm/ui/releases/$VERSION/yao-$VERSION-linux-amd64 scp ~/Code/bin/xiang-$VERSION-darwin-amd64 max@demo-crm.iqka.com:/data/demo-crm/ui/releases/$VERSION/yao-$VERSION-darwin-amd64 -scp ~/Code/bin/xiang-$VERSION-windows-386 max@demo-crm.iqka.com:/data/demo-crm/ui/releases/$VERSION/yao-$VERSION-windows-386 +# scp ~/Code/bin/xiang-$VERSION-windows-386 max@demo-crm.iqka.com:/data/demo-crm/ui/releases/$VERSION/yao-$VERSION-windows-386 repace "s/[0-9]+\.[0-9]+\.[0-9]+/$VERSION/g" scp ~/Code/yao/xiang/shell/install.sh.new max@demo-crm.iqka.com:/data/demo-crm/ui/releases/$VERSION/install.sh