1+ name : Create Release
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*'
7+
8+ permissions :
9+ contents : write
10+
11+ jobs :
12+ build-and-release :
13+ runs-on : ${{ matrix.os }}
14+
15+ strategy :
16+ matrix :
17+ os : [ubuntu-latest, macos-latest, windows-latest]
18+ build-type : [Release]
19+
20+ steps :
21+ - name : Checkout code
22+ uses : actions/checkout@v4
23+
24+ - name : Install dependencies (Linux)
25+ if : runner.os == 'Linux'
26+ run : sudo apt-get update && sudo apt-get install -y build-essential cmake
27+
28+ - name : Configure CMake (Unix)
29+ if : runner.os != 'Windows'
30+ run : cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
31+
32+ - name : Configure CMake (Windows)
33+ if : runner.os == 'Windows'
34+ run : cmake -B build -G "Visual Studio 17 2022"
35+
36+ - name : Build (Unix)
37+ if : runner.os != 'Windows'
38+ run : cmake --build build
39+
40+ - name : Build (Windows)
41+ if : runner.os == 'Windows'
42+ run : cmake --build build --config ${{ matrix.build-type }}
43+
44+ - name : Run Tests (Unix)
45+ if : runner.os != 'Windows'
46+ run : cd build && ./hash_table_demo
47+
48+ - name : Run Tests (Windows)
49+ if : runner.os == 'Windows'
50+ run : cd build && .\${{ matrix.build-type }}\hash_table_demo.exe
51+
52+ - name : Upload Binary Artifact
53+ uses : actions/upload-artifact@v4
54+ with :
55+ name : hash_table_demo-${{ runner.os }}
56+ path : ${{ runner.os == 'Windows' && 'build/Release/hash_table_demo.exe' || 'build/hash_table_demo' }}
57+ retention-days : 1
58+
59+ create-release :
60+ needs : build-and-release
61+ runs-on : ubuntu-latest
62+ if : startsWith(github.ref, 'refs/tags/v')
63+
64+ steps :
65+ - name : Checkout code
66+ uses : actions/checkout@v4
67+
68+ - name : Download all artifacts
69+ uses : actions/download-artifact@v4
70+ with :
71+ path : artifacts
72+
73+ - name : Prepare release assets
74+ run : |
75+ mkdir release-assets
76+ cp artifacts/hash_table_demo-Linux/hash_table_demo release-assets/hash_table_demo-linux-x64
77+ cp artifacts/hash_table_demo-macOS/hash_table_demo release-assets/hash_table_demo-macos-arm64
78+ cp artifacts/hash_table_demo-Windows/hash_table_demo.exe release-assets/hash_table_demo-windows-x64.exe
79+
80+ - name : Generate release notes
81+ run : |
82+ cat > release-notes.md << 'EOF'
83+ ## 🚀 Hash Table v${{ github.ref_name }}
84+
85+ ### ✅ Проверено на платформах:
86+ - 🐧 Linux (x64)
87+ - 🍎 macOS (arm64/x64)
88+ - 🪟 Windows (x64)
89+
90+ ### 📦 Сборка из исходников:
91+ \`\`\`bash
92+ cmake -B build -DCMAKE_BUILD_TYPE=Release
93+ cmake --build build
94+ \`\`\`
95+
96+ Полные изменения: $(git log $(git describe --tags --abbrev=0 HEAD^)..HEAD --oneline)
97+ EOF
98+
99+ - name : Create GitHub Release
100+ uses : softprops/action-gh-release@v2
101+ with :
102+ name : " Release ${{ github.ref_name }}"
103+ body_path : release-notes.md
104+ files : |
105+ release-assets/hash_table_demo-linux-x64
106+ release-assets/hash_table_demo-macos-arm64
107+ release-assets/hash_table_demo-windows-x64.exe
108+ draft : false
109+ prerelease : false
110+ env :
111+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments