Skip to content

Commit

Permalink
tag: v0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
runhey committed Dec 16, 2023
1 parent 5b65226 commit 8a7dbf5
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 8 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/release-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,21 @@ jobs:
id: build
run: flutter build windows
# 打包
- run: Move-Item -Path ".\build\windows\runner\Release" -Destination ".\oasx_${{ steps.get_release.outputs.tag_name }}_windows"
- name: Compress file
uses: a7ul/tar-action@v1.1.0
- name: Package oasx
id: package
uses: actions/setup-python@v4
with:
command: c
files: ./oasx_${{ steps.get_release.outputs.tag_name }}_windows
outPath: ./oasx_${{ steps.get_release.outputs.tag_name }}_windows.tar.gz
python-version: '3.10'
- run: |
python ./script/release_windows_package.py --version ${{ steps.get_release.outputs.version }}
# 发布到 Release
- name: Upload Release Windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./oasx_${{ steps.get_release.outputs.tag_name }}_windows.tar.gz
asset_name: oasx_${{ steps.get_release.outputs.tag_name }}_windows.tar.gz
asset_path: ./oasx_${{ steps.get_release.outputs.tag_name }}_windows.zip
asset_name: oasx_${{ steps.get_release.outputs.tag_name }}_windows.zip
asset_content_type: application/gzip
60 changes: 60 additions & 0 deletions script/release_windows_package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import argparse
import re
import os
import zipfile
import time


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--path",
type=str,
help="xxx",
)
parser.add_argument(
"--version",
type=str,
help="xxx",
)
args, _ = parser.parse_known_args()
if args.path:
release_path = args.path
else:
if os.path.exists("./build/windows/x64/runner/Release/oasx.exe"):
release_path = "./build/windows/x64/runner/Release"
elif os.path.exists("./build/windows/runner/Release/oasx.exe"):
release_path = "./build/windows/runner/Release"
else:
raise FileNotFoundError("No release path found.")
match = re.search(r'build.*Release', release_path)
if match:
release_path = match.group(0)
release_path = release_path.replace('\\', '/')
print(f"Matched string: {release_path}")
else:
print("No match found.")

if args.version:
release_version = args.tag
else:
with open('./CHANGELOG.md', 'r', encoding='utf-8') as file:
log = file.read()
log = re.search(r'v\d+\.\d+\.\d+', log).group(0)
log = log.replace('\n', '').replace('\r', '').replace(' ', '')
release_version = log


# 压缩
zip_filename = f'oasx_{release_version}_windows.zip'
with zipfile.ZipFile(zip_filename, 'w') as zip_file:
# 遍历文件夹中的文件
for foldername, subfolders, filenames in os.walk(release_path):
for filename in filenames:
# 构建文件的完整路径
file_path = os.path.join(foldername, filename)

# 将文件添加到 Zip 文件中
zip_file.write(file_path, os.path.relpath(file_path, release_path))

time.sleep(10)

0 comments on commit 8a7dbf5

Please sign in to comment.