-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (129 loc) · 5.51 KB
/
Copy pathrelease.yml
File metadata and controls
149 lines (129 loc) · 5.51 KB
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
name: Release Python app
run-name: Release ${{ github.ref_name }}
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build:
name: Build app on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["windows-latest", "macos-latest", "ubuntu-latest"]
steps:
- name: Checkout ref
uses: actions/checkout@v5
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install requirements
run: |
pip install -r requirements.txt
pip install pyinstaller
- name: PyInstaller (Terminal GUI)
run: pyinstaller versions/terminal_gui.py --onefile --icon=images/icon.ico --name cmd
- name: PyInstaller (CLI)
run: pyinstaller versions/cli_args.py --onefile --icon=images/icon.ico --name cli
- name: PyInstaller (GUI)
run: pyinstaller versions/gui_gui.py --onefile --icon=images/icon.ico --add-data "images/icon.ico:images" --add-data "images/content_copy.png:images" --name gui
- name: Post-build and pre-upload preparation (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: bash
run: |
mkdir cmd
mkdir cli
mkdir gui
mv dist/cmd.exe dist/cmd/translator-cmd.exe
mv dist/cli.exe dist/cli/translator-cli.exe
mv dist/gui.exe dist/gui/translator-gui.exe
echo "# translator ${{ github.ref_name }}" >> dist/README.md
cat .github/extra-files/partial-README.md >> dist/README.md
echo This was built from ${{ github.repository }} >> dist/README.md
echo The SHA-1 hash of the commit that these were built from is ${{ github.sha }} >> dist/README.md
mkdir dist/licenses
cat .github/extra-files/licenses/google-material-design-icons-license.txt >> dist/licenses/google-material-design-icons-license.txt
cat LICENSE >> dist/licenses/translator-code-license.txt
- name: Post-build and pre-upload preparation (Linux/Mac)
if: ${{ matrix.os != 'windows-latest' }}
run: |
mkdir cmd
mkdir cli
mkdir gui
mv dist/cmd dist/cmd/translator-cmd
mv dist/cli dist/cli/translator-cli
mv dist/gui dist/gui/translator-gui
echo "# translator ${{ github.ref_name }}" >> dist/README.md
cat .github/extra-files/partial-README.md >> dist/README.md
echo This was built from ${{ github.repository }} >> dist/README.md
echo The SHA-1 hash of the commit that these were built from is ${{ github.sha }} >> dist/README.md
mkdir dist/licenses
cat .github/extra-files/licenses/google-material-design-icons-license.txt >> dist/licenses/google-material-design-icons-license.txt
cat LICENSE >> dist/licenses/translator-code-license.txt
- name: List dist directory
run: ls -R dist
- name: Tar files on Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
chmod +x dist/cmd/translator-cmd
chmod +x dist/cli/translator-cli
chmod +x dist/gui/translator-gui
tar -czvf output/translator@${{ github.ref_name }}_${{ matrix.os }}.tar.gz dist/
rm -rf dist/
- name: Zip folder on Mac
if: ${{ matrix.os == 'macos-latest' }}
run: |
zip -r translator@${{ github.ref_name }}_${{ matrix.os }}.zip dist/
rm -rf dist/
mkdir output/
mv translator@${{ github.ref_name }}_${{ matrix.os }}.zip output/
- name: Zip folder on Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
$itemsToZip = @(".\dist\translator-cmd", ".\dist\translator-cli", ".\dist\translator-gui", ".\dist\README.md", ".\dist\licenses\")
Compress-Archive -Path $itemsToZip -DestinationPath ".\output\translator@${{ github.ref_name }}_${{ matrix.os }}.zip"
if (Test-Path ".\dist\translator@${{ github.ref_name }}_${{ matrix.os }}.zip") {
foreach ($item in $itemsToZip) {
Remove-Item -Path $item -Recurse -Force
}
Write-Output "Files zipped and originals deleted successfully."
exit 0
} else {
Write-Output "Failed to create zip file. Source files were not deleted."
exit 1
}
- name: Upload debug builds
uses: actions/upload-artifact@v4
with:
name: translator_${{ github.ref_name }}_${{ matrix.os }}_build
path: build/*
- name: Upload distributable builds
uses: actions/upload-artifact@v4
with:
name: translator_${{ github.ref_name }}_${{ matrix.os }}_dist
path: output/*
normal_release:
name: Draft normal release
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: release-artifacts
pattern: "*_dists"
- name: List release-artifacts directory # debug
run: ls -R release-artifacts
- name: Draft normal release
uses: ncipollo/release-action@v1.14.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true
tag: ${{ github.ref_name }}
artifacts: release-artifacts/translator_*_dist/*
draft: true
name: "Release ${{ github.ref_name }}"
body: "CLI & CMD users should add the artifact to their system PATH. Look it up online if you don't know how."