-
Notifications
You must be signed in to change notification settings - Fork 2
88 lines (79 loc) · 2.5 KB
/
macos-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Build macOS App
on:
release:
types: [published, edited]
workflow_dispatch:
jobs:
build:
runs-on: macos-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build macOS app
run: |
pyinstaller project_exporter.spec
echo "Contents of dist directory:"
ls -R dist
- name: Create ZIP archive
run: |
cd dist
zip -r "../Project_Exporter-macOS.zip" "项目文件导出工具.app"
cd ..
echo "Contents of current directory:"
ls -l
- name: Get Release
id: get_release
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
let release;
if (context.payload.release) {
release = context.payload.release;
} else {
const response = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
release = response.data;
}
core.setOutput('upload_url', release.upload_url);
core.setOutput('release_id', release.id);
- name: Delete existing asset
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const releaseId = '${{ steps.get_release.outputs.release_id }}';
const { data: assets } = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: releaseId,
});
const asset = assets.find(a => a.name === 'Project_Exporter-macOS.zip');
if (asset) {
await github.rest.repos.deleteReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
asset_id: asset.id,
});
}
- name: Upload Release Asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./Project_Exporter-macOS.zip
asset_name: Project_Exporter-macOS.zip
asset_content_type: application/zip