Skip to content

Commit

Permalink
添加自动编译上传功能
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoXianNv-boot committed Mar 3, 2024
1 parent 7dd83c6 commit 494339f
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 生成包和二进制文件

#run-name: ${{ github.actor }} is learning GitHub Actions

on: [push]

jobs:
生成包和二进制文件:
runs-on: ubuntu-latest
steps:
- name: 获取存储库
uses: actions/checkout@v4
- name: 安装依赖
run: apt install -y p7zip-full && sudo dpkg --add-architecture i386 && sudo mkdir -pm755 /etc/apt/keyrings && sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key && sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources && sudo apt update && sudo apt install -y --install-recommends winehq-stable
- name: 生成包
run: python3 actions.py
- name: 上传包 pkg
uses: softprops/action-gh-release@v1
if: true
with:
tag_name: pkg
name: pkg
body: pkg 软件包
draft: false
prerelease: false
files: |
.jcm/pkg/*
164 changes: 164 additions & 0 deletions actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# coding=utf-8
#!/bin/python

import os
import sys
import imp

def mkdir(name):
if os.path.exists(name) == False:
os.mkdir(name)

print('pkg out V1.0')

#os.system("rm -rf .jcm/pkg/Packages")
os.system("rm -rf .jcm/*/Packages")

path = os.listdir("./server")
for p in path:
p = "server/" + p
if os.path.isdir(p):
if os.path.isfile(p + "/Package.py"):
Package = ''
name = ''
Version = ''
Depends = ''
License = ''
issued = 'pkg'
Description = ''.split('\r')[0]
shrun = os.popen("\"" + sys.executable + "\" " + p + "/Package.py prin")
data = shrun.buffer.read().decode(encoding='utf8')
datas = data.split('\n')
for p in datas:
pp = p.split(':')
if pp[0] == "Package":
Package = pp[1].split('\r')[0]
if pp[0] == "name":
name = pp[1].split('\r')[0]
if pp[0] == "Version":
Version = pp[1].split('\r')[0]
if pp[0] == "Depends":
Depends = pp[1].split('\r')[0]
if pp[0] == "License":
License = pp[1].split('\r')[0]
if pp[0] == "issued":
issued = pp[1].split('\r')[0]
if pp[0] == "Description":
Description = pp[1].split('\r')[0]
os.system("rm -rf .out")
os.mkdir(".out")
os.mkdir(".out/language")
os.mkdir(".out/language/server")
os.mkdir(".out/server")
os.mkdir(".out/web")
os.mkdir('.out/web/Ace_Admin')
runout = imp.load_source('run',"server/" + Package + "/Package.py")
runout.out()
os.system("tar czf .pkg.tar.xz .out")
mkdir(".jcm")
mkdir(".jcm/" + issued)
os.system("mv .pkg.tar.xz .jcm/" + issued + "/" + Package + '_' + Version + '.pkg')
print(Package + '_' + Version + '.pkg')

print( 'out Packages file....')
jcm = os.listdir(".jcm")
for i in jcm:
path = os.listdir(".jcm/" + i)
print( 'out ' + i)
for p in path:
#print('.')
Package = ''
name = ''
Version = ''
Depends = ''
License = ''
issued = 'pkg'
os.system("rm -rf .out")
os.mkdir(".out")
os.system("tar xzf .jcm/" + i + "/" + p + " .out")
shrun = os.popen("\"" + sys.executable + "\" .out/server/" + p.split('_')[0] + "/Package.py prin")
data = shrun.buffer.read().decode(encoding='utf8')
datas = data.split('\n')
for p in datas:
pp = p.split(':')
if pp[0] == "Package":
Package = pp[1].split('\r')[0]
if pp[0] == "name":
name = pp[1].split('\r')[0]
if pp[0] == "Version":
Version = pp[1].split('\r')[0]
if pp[0] == "Depends":
Depends = pp[1].split('\r')[0]
if pp[0] == "License":
License = pp[1].split('\r')[0]
if pp[0] == "issued":
issued = pp[1].split('\r')[0]
if pp[0] == "Description":
Description = pp[1].split('\r')[0]
fs = open(".jcm/" + i + "/Packages","ab")
fs.write(('Package:' + Package + '\n').encode("utf-8"))
fs.write(('name:' + name + '\n').encode("utf-8"))
fs.write(('Version:' + Version + '\n').encode("utf-8"))
fs.write(('Depends:' + Depends + '\n').encode("utf-8"))
fs.write(('License:' + License + '\n').encode("utf-8"))
fs.write(('Description:' + Description + '\n\n').encode("utf-8"))
fs.close()
print(Package + '_' + Version + '.pkg')
print('end')

def rm(dir,name):
path = os.listdir(dir)
for p in path:
if os.path.isdir(dir + p):
if p == name:
os.system("rm -rf " + dir + name)
else:
rm(dir + p + '/',name)

rm('./','__pycache__')

print("out files .jcm/ ")

mkdir("jcm")
mkdir("jcm/pkg")
mkdir("jcm/install")
os.system("cp .jcm/pkg/* jcm/pkg/")

print("make Windows exe ...")
# apt install p7zip-full
# sudo dpkg --add-architecture i386
# sudo mkdir -pm755 /etc/apt/keyrings
# sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
# Ubuntu 22.04
# sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources
# Ubuntu 20.04
# Linux Mint 20.x
# sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources
# Ubuntu 18.04
# Linux Mint 19.x
# sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/bionic/winehq-bionic.sources
# Debian 12 Bookworm
# sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/debian/dists/bookworm/winehq-bookworm.sources
# Debian 11 Bullseye
# sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/debian/dists/bullseye/winehq-bullseye.sources

# sudo apt update
# sudo apt install --install-recommends winehq-stable



os.system("rm -rf .out")
os.mkdir(".out")
# #为注释,不执行此命令
os.system("cd .out \
&& 7z x ../lib/python-3.6.7.7z \
&& cd Tools/.python/ \
&& wine python.exe -m pip install pyinstaller \
&& wine python.exe -m pip install requests \
&& cp ../../../Tools/install.py ./ \
&& wine Scripts/pyinstaller.exe -F --hidden-import requests -c --uac-admin install.py \
&& cp dist/install.exe ../../../jcm/install/ ")
os.system("cp Tools/install.py jcm/install/")
os.system("cp Tools/install.sh jcm/install/")
os.system("cp language/Tools/install.py jcm/install/language -rf")
os.system("rm -rf .out")

0 comments on commit 494339f

Please sign in to comment.