Skip to content
This repository was archived by the owner on Apr 13, 2022. It is now read-only.

Commit 7eb4690

Browse files
committed
chore: 增加GithubActions打包
1 parent f9dc3a3 commit 7eb4690

3 files changed

Lines changed: 142 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
on:
2+
push:
3+
tags:
4+
- "v*"
5+
6+
jobs:
7+
build:
8+
runs-on: windows-2019
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
13+
# - name: Load Cache
14+
# uses: actions/cache@v2
15+
# with:
16+
# path: .\venv
17+
# key: ${{ hashFiles('**/requirements.txt') }}
18+
19+
- name: Check Out Tag-Name
20+
id: checkout-tagname
21+
shell: "python3 {0}"
22+
run: |
23+
import os
24+
import re
25+
ref = os.getenv('GITHUB_REF', '')
26+
match = re.search(r'refs\/tags\/(.*)', ref)
27+
tag_name = match[1] if match is not None else ''
28+
print('::set-output name=tag_name::'+tag_name)
29+
30+
- name: Build
31+
env:
32+
tag_name: ${{ steps.checkout-tagname.outputs.tag_name }}
33+
run: |
34+
tzutil /s "China Standard Time"
35+
python -m pip install wheel setuptools virtualenv
36+
python -m virtualenv venv
37+
venv\Scripts\activate
38+
pip install -r requirements.txt
39+
40+
pyinstaller --noconfirm -i icon.ico -c -F -n LittleServer-${{ env.tag_name }} LittleServerMain.py
41+
copy config.exam.yml dist\config.yml
42+
43+
- name: Print Hashes
44+
env:
45+
tag_name: ${{ steps.checkout-tagname.outputs.tag_name }}
46+
run: |
47+
python ci\hash_tool.py dist\LittleServer-${{ env.tag_name }}.exe
48+
49+
- name: Upload To Github Release
50+
uses: xresloader/upload-to-github-release@98857380fc282f8075a62c6af230fe92bd93aff8
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.TOKEN }}
53+
with:
54+
file: dist/*
55+
draft: false
56+
tags: true

ci/generate_version_file.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
if __name__ == "__main__":
2+
import sys
3+
4+
if len(sys.argv) < 4:
5+
print('productName, productVersion, versionfileName are required to be passed.')
6+
sys.exit(1)
7+
8+
productName = sys.argv[1]
9+
productVersion = sys.argv[2]
10+
output = sys.argv[3]
11+
12+
template = f'''
13+
# UTF-8
14+
#
15+
# For more details about fixed file info 'ffi' see:
16+
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
17+
VSVersionInfo(
18+
ffi=FixedFileInfo(
19+
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
20+
# Set not needed items to zero 0.
21+
filevers=(1, 0, 0, 0),
22+
prodvers=(1, 0, 0, 0),
23+
# Contains a bitmask that specifies the valid bits 'flags'r
24+
mask=0x3f,
25+
# Contains a bitmask that specifies the Boolean attributes of the file.
26+
flags=0x0,
27+
# The operating system for which this file was designed.
28+
# 0x4 - NT and there is no need to change it.
29+
OS=0x4,
30+
# The general type of file.
31+
# 0x1 - the file is an application.
32+
fileType=0x1,
33+
# The function of the file.
34+
# 0x0 - the function is not defined for this fileType
35+
subtype=0x0,
36+
# Creation date and time stamp.
37+
date=(0, 0)
38+
),
39+
kids=[
40+
StringFileInfo(
41+
[StringTable(
42+
u'000004b0',
43+
[
44+
StringStruct(u'Comments', u''),
45+
StringStruct(u'CompanyName', u''),
46+
StringStruct(u'FileDescription', u''),
47+
StringStruct(u'FileVersion', u'1.0.0.0'),
48+
StringStruct(u'InternalName', u''),
49+
StringStruct(u'LegalCopyright', u''),
50+
StringStruct(u'LegalTrademarks', u''),
51+
StringStruct(u'OriginalFilename', u''),
52+
StringStruct(u'ProductName', u'{productName}'),
53+
StringStruct(u'ProductVersion', u'{productVersion}'),
54+
StringStruct(u'Assembly Version', u'1.0.0.0')
55+
]
56+
)
57+
]),
58+
VarFileInfo([VarStruct(u'Translation', [0, 1200])
59+
])
60+
]
61+
)
62+
'''
63+
64+
with open(output, "w+", encoding="utf-8") as f:
65+
f.write(template)

ci/hash_tool.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import sys
2+
import hashlib
3+
4+
if len(sys.argv) < 2:
5+
print('file to be hashed is required!')
6+
sys.exit(1)
7+
8+
file = sys.argv[1]
9+
10+
def hash(fileToBeHashed, hashobj):
11+
with open(fileToBeHashed, 'rb') as f:
12+
hashobj.update(f.read())
13+
return hashobj.hexdigest()
14+
15+
def show_hash(f, hashobj):
16+
print(hashobj.name+': '+hash(f, hashobj))
17+
18+
print('hashes for '+file)
19+
show_hash(file, hashlib.md5())
20+
show_hash(file, hashlib.sha1())
21+
show_hash(file, hashlib.sha256())

0 commit comments

Comments
 (0)