Repository navigation
153 lines (137 loc) · 5.18 KB
/
Copy pathbuild-and-upload.yml
File metadata and controls
153 lines (137 loc) · 5.18 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
150
151
152
153
name: Build and upload
on:
release:
types: [published]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
configure:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix
id: set-matrix
run: |
if [[ "${{ github.repository }}" == "mistralai/albert-code" ]]; then
matrix='{
"include": [
{"runner": "ubuntu-22.04", "os": "linux", "arch": "x86_64"},
{"runner": "ubuntu-22.04-arm", "os": "linux", "arch": "aarch64"},
{"runner": "macos-15-intel", "os": "darwin", "arch": "x86_64"},
{"runner": "macos-14", "os": "darwin", "arch": "aarch64"},
{"runner": "windows-2022", "os": "windows", "arch": "x86_64"},
{"runner": "windows-11-arm", "os": "windows", "arch": "aarch64"}
]
}'
else # skip ARM Linux/Windows (runners not available on non public repos)
matrix='{
"include": [
{"runner": "ubuntu-22.04", "os": "linux", "arch": "x86_64"},
{"runner": "macos-15-intel", "os": "darwin", "arch": "x86_64"},
{"runner": "macos-14", "os": "darwin", "arch": "aarch64"},
{"runner": "windows-2022", "os": "windows", "arch": "x86_64"}
]
}'
fi
echo "matrix=$(echo $matrix | jq -c .)" >> $GITHUB_OUTPUT
build-and-upload:
needs: configure
name: ${{ matrix.os }}-${{ matrix.arch }}
permissions:
contents: read
strategy:
matrix: ${{ fromJSON(needs.configure.outputs.matrix) }}
runs-on: ${{ matrix.runner }}
steps:
- name: echo
run: echo github.repository=${{ github.repository }}
- name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
cache: pip
- name: Install package and PyInstaller
shell: bash
run: |
python -m venv .venv
if [ "${{ runner.os }}" = "Windows" ]; then
source .venv/Scripts/activate
else
source .venv/bin/activate
fi
pip install --upgrade pip
pip install -e .
pip install "pyinstaller>=6.17.0"
- name: Build with PyInstaller (Unix)
if: ${{ matrix.os != 'windows' }}
run: |
source .venv/bin/activate
pyinstaller albert-acp.spec
- name: Build with PyInstaller (Windows)
if: ${{ matrix.os == 'windows' }}
shell: pwsh
run: |
.\.venv\Scripts\Activate.ps1
pyinstaller albert-acp.spec
- name: Get package version (Unix)
id: get_version_unix
if: ${{ matrix.os != 'windows' }}
run: |
source .venv/bin/activate
version=$(python -c "from importlib.metadata import version; print(version('albert-code'))")
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Get package version (Windows)
id: get_version_windows
if: ${{ matrix.os == 'windows' }}
shell: pwsh
run: |
.\.venv\Scripts\Activate.ps1
$version = python -c "from importlib.metadata import version; print(version('albert-code'))"
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Upload binary as artifact (Unix)
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5
if: ${{ matrix.os != 'windows' }}
with:
name: albert-acp-${{ matrix.os }}-${{ matrix.arch }}-${{ steps.get_version_unix.outputs.version }}
path: dist/albert-acp
- name: Upload binary as artifact (Windows)
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5
if: ${{ matrix.os == 'windows' }}
with:
name: albert-acp-${{ matrix.os }}-${{ matrix.arch }}-${{ steps.get_version_windows.outputs.version }}
path: dist/albert-acp.exe
attach-to-release:
needs: build-and-upload
runs-on: ubuntu-latest
if: github.event_name == 'release'
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
with:
path: artifacts
- name: Zip artifacts
run: |
mkdir release-assets
for dir in artifacts/*; do
name=$(basename "$dir")
if [ -f "$dir/albert-acp" ]; then
chmod +x "$dir/albert-acp"
zip -j "release-assets/${name}.zip" "$dir/albert-acp"
elif [ -f "$dir/albert-acp.exe" ]; then
zip -j "release-assets/${name}.zip" "$dir/albert-acp.exe"
fi
done
- name: Attach binaries to release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2
with:
files: release-assets/*.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}