-
Notifications
You must be signed in to change notification settings - Fork 1
173 lines (150 loc) · 5.42 KB
/
Copy pathbuild-executables.yml
File metadata and controls
173 lines (150 loc) · 5.42 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Build Executables
permissions:
contents: write
on:
push:
branches:
- main
- develop
tags:
- 'v*'
pull_request:
branches:
- main
- develop
workflow_dispatch:
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact_name: mth5-validator
asset_name: mth5-validator-linux-amd64
- os: windows-latest
artifact_name: mth5-validator.exe
asset_name: mth5-validator-windows-amd64.exe
- os: macos-latest
artifact_name: mth5-validator
asset_name: mth5-validator-macos-amd64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build executable
working-directory: src
run: python build_standalone_validator.py
- name: Test executable (Linux/macOS)
if: runner.os != 'Windows'
working-directory: src
run: |
chmod +x dist/${{ matrix.artifact_name }}
./dist/${{ matrix.artifact_name }} --help
- name: Test executable (Windows)
if: runner.os == 'Windows'
working-directory: src
run: |
dist\${{ matrix.artifact_name }} --help
- name: Get file size
id: filesize
shell: bash
working-directory: src
run: |
SIZE=$(stat -c%s "dist/${{ matrix.artifact_name }}" 2>/dev/null || stat -f%z "dist/${{ matrix.artifact_name }}")
SIZE_MB=$(python -c "print(f'{$SIZE / 1048576:.2f}')")
echo "size_mb=$SIZE_MB" >> $GITHUB_OUTPUT
echo "Executable size: $SIZE_MB MB"
- name: Rename artifact
shell: bash
working-directory: src
run: |
cp dist/${{ matrix.artifact_name }} dist/${{ matrix.asset_name }}
- name: Package Windows executable in zip
if: runner.os == 'Windows'
shell: pwsh
working-directory: src/dist
run: |
Compress-Archive -Path ${{ matrix.asset_name }} -DestinationPath ${{ matrix.asset_name }}.zip
- name: Upload artifact (Windows zip)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}.zip
path: src/dist/${{ matrix.asset_name }}.zip
retention-days: 30
- name: Upload artifact (Linux/macOS)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: src/dist/${{ matrix.asset_name }}
retention-days: 30
- name: Create checksum
shell: bash
working-directory: src/dist
run: |
if [ "${{ runner.os }}" == "Windows" ]; then
certutil -hashfile ${{ matrix.asset_name }} SHA256 | findstr /v ":" | findstr /v "SHA" > ${{ matrix.asset_name }}.sha256
else
shasum -a 256 ${{ matrix.asset_name }} > ${{ matrix.asset_name }}.sha256
fi
- name: Create checksum for Windows zip
if: runner.os == 'Windows'
shell: pwsh
working-directory: src/dist
run: |
$hash = (Get-FileHash -Algorithm SHA256 "${{ matrix.asset_name }}.zip").Hash
"$hash ${{ matrix.asset_name }}.zip" | Out-File -FilePath "${{ matrix.asset_name }}.zip.sha256" -Encoding ASCII
- name: Upload checksum
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}.sha256
path: src/dist/${{ matrix.asset_name }}.sha256
retention-days: 30
- name: Upload checksum for Windows zip
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}.zip.sha256
path: src/dist/${{ matrix.asset_name }}.zip.sha256
retention-days: 30
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -R artifacts
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: false
generate_release_notes: true
files: |
artifacts/mth5-validator-linux-amd64/mth5-validator-linux-amd64
artifacts/mth5-validator-linux-amd64.sha256/mth5-validator-linux-amd64.sha256
artifacts/mth5-validator-windows-amd64.exe.zip/mth5-validator-windows-amd64.exe.zip
artifacts/mth5-validator-windows-amd64.exe.zip.sha256/mth5-validator-windows-amd64.exe.zip.sha256
artifacts/mth5-validator-macos-amd64/mth5-validator-macos-amd64
artifacts/mth5-validator-macos-amd64.sha256/mth5-validator-macos-amd64.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}