-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (159 loc) · 5.43 KB
/
package.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: package_release
on:
push:
tags:
- '*.*.*'
pull_request:
jobs:
test-package:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
py_ver:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py_ver }}
- name: Install Package
run: pip install .
- name: Test Package
env:
PY_VER: ${{ matrix.py_ver }}
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
CHANNEL_ID: ${{ secrets.CHANNEL_ID }}
USERNAME: ${{ secrets.USERNAME }}
PYTHONUNBUFFERED: 1
run: |
touch .env.test
export VERSION=$(cat discordai/version.py | grep -oP '\d+\.\d+\.\d+')
docker compose -f docker-compose-test.yaml up --build --exit-code-from tests
release:
if: |
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.repository_owner == 'A-Baji'
needs: test-package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: version
name: Get build metadata
run: echo "::set-output name=discordai_version::$(cat discordai/version.py | grep -oP '\d+\.\d+\.\d+')"
- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.discordai_version }}
release_name: Release ${{ steps.version.outputs.discordai_version }}
body: Release ${{ steps.version.outputs.discordai_version }}
draft: false
prerelease: false
package:
needs: test-package
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- windows-latest
# - macos-latest
- ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install Dependencies
run: pip install . pyinstaller
# Package
- name: Windows CLI Package
if: ${{ matrix.os == 'windows-latest' }}
run: |
pyinstaller discordai/command_line/command_line.py --console --onefile --name=discordai --add-binary='discordai/bot/cogs;discordai/bot/cogs' --hidden-import=openai --collect-data=discordai_modelizer
Compress-Archive -Path dist\*discordai* -DestinationPath discordai-windows.zip
- name: Mac CLI Package
if: ${{ matrix.os == 'macos-latest' }}
run: |
pyinstaller discordai/command_line/command_line.py --console --onefile --name=discordai --add-data='discordai/bot/cogs:discordai/bot/cogs' --hidden-import=openai --hidden-import=configparser --collect-data=discordai_modelizer --collect-data=aiohttp --collect-data=certifi
zip -j discordai-macos.zip dist/*discordai*
chmod +x dist/*discordai*
- name: Linux CLI Package
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
pyinstaller discordai/command_line/command_line.py --console --onefile --name=discordai --add-binary='discordai/bot/cogs:discordai/bot/cogs' --hidden-import=openai --collect-data=discordai_modelizer
zip -j discordai-linux.zip dist/*discordai*
chmod +x dist/*discordai*
# Upload
- name: Upload Windows Package to Artifacts
if: |
matrix.os == 'windows-latest' &&
github.event_name != 'push' &&
!startsWith(github.ref, 'refs/tags')
uses: actions/upload-artifact@v3
with:
name: discordai-windows
path: dist/*discordai*
retention-days: 1
- name: Upload Windows Package to Release
if: |
matrix.os == 'windows-latest' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.repository_owner == 'A-Baji'
uses: softprops/action-gh-release@v1
with:
files: ./*discordai*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Mac Package to Artifacts
if: |
matrix.os == 'macos-latest' &&
github.event_name != 'push' &&
!startsWith(github.ref, 'refs/tags')
uses: actions/upload-artifact@v3
with:
name: discordai-macos
path: dist/*discordai*
retention-days: 1
- name: Upload Mac Package to Release
if: |
matrix.os == 'macos-latest' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.repository_owner == 'A-Baji'
uses: softprops/action-gh-release@v1
with:
files: ./*discordai*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Linux Package to Artifacts
if: |
matrix.os == 'ubuntu-latest' &&
github.event_name != 'push' &&
!startsWith(github.ref, 'refs/tags')
uses: actions/upload-artifact@v3
with:
name: discordai-linux
path: dist/*discordai*
retention-days: 1
- name: Upload Linux Package to Release
if: |
matrix.os == 'ubuntu-latest' &&
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
github.repository_owner == 'A-Baji'
uses: softprops/action-gh-release@v1
with:
files: ./*discordai*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}