[doc] Add development docs #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Qbot-Build-Release | |
on: | |
push: | |
branches: [main] | |
paths-ignore: | |
- "**.md" | |
- "**.spec.js" | |
- ".idea" | |
- ".vscode" | |
- ".dockerignore" | |
- "Dockerfile" | |
- ".gitignore" | |
- ".github/**" | |
- "!.github/workflows/qbot-release.yml" | |
tags: | |
- v* | |
jobs: | |
fund_strategy_release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macos-latest, ubuntu-latest] | |
python-version: [3.8] | |
environment: fund_strategy | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 14 | |
- name: Cache Node Dependencies | |
id: cache | |
uses: actions/cache@v1 | |
with: | |
path: node_modules | |
key: ${{runner.OS}}-npm-caches-${{ hashFiles('package-lock.json') }} | |
- name: Install Dependencies | |
run: | | |
cd $GITHUB_WORKSPACE/pyfunds/fund-strategies | |
npm install | |
- name: Build Release Files | |
run: | | |
cd $GITHUB_WORKSPACE/pyfunds/fund-strategies | |
npm run build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release_on_${{ matrix.os }} | |
path: dist/ | |
retention-days: 5 | |
# - name: 'Publish to the npm registry' | |
# uses: primer/publish@3.0.0 | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
# with: | |
# default_branch: 'main' | |
release: | |
name: Create Release | |
runs-on: ${{ matrix.os }} | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
strategy: | |
matrix: | |
# os: [ubuntu-20.04, macos-11.0, windows-2019] | |
os: [macos-11.0] | |
python-version: [3.8] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
draft: true | |
prerelease: true | |
tag_name: ${{ github.ref }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
investool_app_release: | |
runs-on: ubuntu-latest | |
needs: release | |
timeout-minutes: 15 | |
env: | |
tag_name: v1.0.0 | |
release_name: investool_app_ubuntu_$tag_name | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.18 | |
# - name: Test | |
# run: go test -race ./... | |
- name: Build For Mac | |
run: | | |
cd $GITHUB_WORKSPACE/investool | |
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=`TZ=Asia/Shanghai date +'%y%m%d%H%M'`" -o investool_app_mac | |
- name: Tar [Mac] | |
run: | | |
cd $GITHUB_WORKSPACE/investool | |
if [[ "$(uname)" == "Darwin" ]]; then | |
sed -i '' 's/env = "localhost"/env = "prod"/' config.toml | |
else | |
sed -i "s/env = \"localhost\"/env = \"prod\"/g" config.toml | |
fi | |
tar czvf investool_app_mac.tar.gz investool_app_mac config.toml | |
- name: Build For Linux | |
run: | | |
cd $GITHUB_WORKSPACE/investool | |
CGO_ENABLED=0 GOOS=linux go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=`TZ=Asia/Shanghai date +'%y%m%d%H%M'`" -o investool_app_linux | |
- name: Tar [Linux] | |
run: | | |
cd $GITHUB_WORKSPACE/investool | |
if [[ "$(uname)" == "Darwin" ]]; then | |
sed -i '' 's/env = "localhost"/env = "prod"/' config.toml | |
else | |
sed -i "s/env = \"localhost\"/env = \"prod\"/g" config.toml | |
fi | |
tar czvf investool_app_linux.tar.gz investool_app_linux config.toml | |
- name: Build For Win | |
run: | | |
cd $GITHUB_WORKSPACE/investool | |
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-X github.com/axiaoxin-com/investool/version.Version=`TZ=Asia/Shanghai date +'%y%m%d%H%M'`" -o investool_app_win | |
- name: Tar [Win] | |
run: | | |
cd $GITHUB_WORKSPACE/investool | |
if [[ "$(uname)" == "Darwin" ]]; then | |
sed -i '' 's/env = "localhost"/env = "prod"/' config.toml | |
else | |
sed -i "s/env = \"localhost\"/env = \"prod\"/g" config.toml | |
fi | |
tar czvf investool_app_win.tar.gz investool_app_win config.toml | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
draft: false | |
prerelease: false | |
tag_name: ${{ github.ref }} | |
- name: Upload assets | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: $GITHUB_WORKSPACE/investool/investool_app_mac.tar.gz | |
asset_name: investool_app_mac.tar.gz | |
asset_content_type: application/gzip | |
# - name: SCP Files | |
# uses: appleboy/scp-action@master | |
# with: | |
# host: ${{ secrets.REMOTE_HOST }} | |
# username: ${{ secrets.REMOTE_USER }} | |
# port: ${{ secrets.REMOTE_PORT }} | |
# key: ${{ secrets.SERVER_SSH_KEY }} | |
# source: 'investool_app_mac.tar.gz, investool_app_linux.tar.gz, investool_app_win.tar.gz' | |
# target: ${{ secrets.REMOTE_TARGET }} | |
# - name: SSH Remote Commands | |
# uses: appleboy/ssh-action@master | |
# with: | |
# host: ${{ secrets.REMOTE_HOST }} | |
# username: ${{ secrets.REMOTE_USER }} | |
# port: ${{ secrets.REMOTE_PORT }} | |
# key: ${{ secrets.SERVER_SSH_KEY }} | |
# script: ${{ secrets.AFTER_COMMAND }} | |
qbot_build: | |
name: Build Qbot | |
needs: release | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, macos-11.0, windows-2019] | |
python-version: [3.8] | |
env: | |
tag_name: v1.0.0 | |
release_name: qbot_${{ matrix.os}}_$tag_name | |
steps: | |
- name: Setup Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install pyinstaller | |
- name: Build | |
run: | | |
pyinstaller -F -w --clean --add-data gui/bkt_result/bkt_result.html:gui/bkt_result/bkt_result.html --add-data gui/imgs/wechat.png:gui/imgs/wechat.png main.py -n qbot --icon=./gui/imgs/logo.ico | |
- name: Package | |
working-directory: . | |
run: | | |
tar -zcvf ${release_name}.tar.gz ./dist | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
draft: false | |
prerelease: false | |
tag_name: ${{ github.ref }} | |
- name: Upload assets | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: ${release_name}.tar.gz | |
asset_name: ${release_name}.tar.gz | |
asset_content_type: application/gzip | |
qbot_package: | |
name: Package Qbot all | |
needs: [qbot_build, investool_app_release, fund_strategy_release] | |
runs-on: ${{ matrix.os }} | |
env: | |
tag_name: v1.0.0 | |
release_name: qbot_${{ matrix.os}}_$tag_name | |
defaults: | |
run: | |
working-directory: Qbot | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, macos-11.0, windows-2019] | |
python-version: [3.8] | |
steps: | |
- name: Package ${{ matrix.python-version }} ${{ matrix.os }} | |
working-directory: . | |
run: | | |
mv *.tar.gz *.zip qbot_${{ matrix.os }}_release | |
tar -zcvf qbot_${{ matrix.os }}_release_${release_name}.tar.gz qbot_${{ matrix.os }}_release/* | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
draft: false | |
prerelease: false | |
tag_name: ${{ github.ref }} | |
- name: Upload assets | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: qbot_${{ matrix.os }}_release_${release_name}.tar.gz | |
asset_name: qbot_${{ matrix.os }}_release_${release_name}.tar.gz | |
asset_content_type: application/gzip |