Browse Source

feat: 💚 Build CI

tags/0.1.0
shangfengh 2 years ago
parent
commit
82f8c0684d
2 changed files with 78 additions and 32 deletions
  1. +49
    -32
      .github/workflows/upload_COS.yml
  2. +29
    -0
      dependency/py/HashFiles.py

+ 49
- 32
.github/workflows/upload_COS.yml View File

@@ -7,10 +7,50 @@ name: "upload_COS"

on:
push:
branches: [ main, dev ]
branches: [ main, dev , new]

jobs:
client_build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup dotnet Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9.2'
architecture: 'x64'


- name: Pip Install paramiko
run: pip install paramiko

- name: Publish
run: |
mkdir -p ./THUAI6/win/win64
dotnet publish "./logic/Client/Client.csproj" -c Release -r win-x64 -o ./THUAI6/win/win64 --self-contained true
rm ./THUAI6/win/win64/System.*.dll

- name: Hash Files
run: |
python ./dependency/py/HashFiles.py -t ./THUAI6/

- name: Save Primes
id: cache-primes-save
uses: actions/cache/save@v3
with:
path: |
./THUAI6
key: ${{ runner.os }}-${{ hashFiles('./THUAI6/hash.json') }}

build_upload:
needs: client_build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@@ -28,8 +68,13 @@ jobs:
- name: Pip Install paramiko
run: pip install paramiko

#
# dotnet publish "./logic/Client/Client.csproj" -c Release -r win-x64 -o ./THUAI6/win/win64 --self-contained true
- name: Restore cached Primes
id: cache-primes-restore
uses: actions/cache/restore@v3
with:
path: |
./THUAI6
key: ${{ client_build.steps.cache-primes-save.outputs.cache-primary-key }}

- name: Publish
run: |
@@ -104,32 +149,4 @@ jobs:
secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
bucket: ${{ secrets.COS_BUCKET }}
region: ${{ secrets.COS_REGION }}

client_build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup dotnet Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9.2'
architecture: 'x64'


- name: Pip Install paramiko
run: pip install paramiko

- name: Publish
run: |
mkdir -p THUAI6/win/win64
dotnet publish "./logic/Client/Client.csproj" -c Release -r win-x64 -o ./THUAI6/win/win64 --self-contained true
rm ./THUAI6/win/win64/System.*.dll
rm ./THUAI6/win/win64/Debug/System.*.dll
region: ${{ secrets.COS_REGION }}

+ 29
- 0
dependency/py/HashFiles.py View File

@@ -0,0 +1,29 @@
# -*- coding=utf-8
import sys
import os
import argparse
import getopt
import hashlib
import json

def generateHashFile():
file = targetfolder
hashlist={}
for root, dirs, files in os.walk(file):
for file in files:
path = os.path.join(root, file)
with open(path, 'rb') as f:
data = f.read()
hashlist[path.replace('\\','/')]=hashlib.md5(data).hexdigest()
targetFile=os.path.join(targetfolder,'hash.json')
with open(targetFile, 'w') as fp:
json.dump(hashlist,fp)
parser = argparse.ArgumentParser()
parser.add_argument('-t',type=str)

args=parser.parse_args()

targetfolder = args.t

generateHashFile()

Loading…
Cancel
Save