-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (128 loc) · 4.58 KB
/
multi-build.yml
File metadata and controls
147 lines (128 loc) · 4.58 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
name: Global Release Automation
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version to release (e.g. v2.5.10)"
required: true
default: "v2.5.10"
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
outputs:
version: ${{ env.RELEASE_VERSION }}
env:
RELEASE_VERSION: ${{ github.event.inputs.version || github.ref_name }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: x64_linux_ubuntu
binary: cortex
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: x64_linux_fedora_arch
binary: cortex
- os: macos-14 # Specifically for Apple Silicon (macOS 14+)
target: aarch64-apple-darwin
suffix: arm64_macos
binary: cortex
- os: macos-14 # Standard stable runner
target: x86_64-apple-darwin
suffix: x64_macos
binary: cortex
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: x64_windows
binary: cortex.exe
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Rust Toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Rust Cache
uses: swatinem/rust-cache@v2
- name: Build Rust Core
working-directory: rust
run: cargo build --release --target ${{ matrix.target }}
env:
PYO3_PYTHON: python
- name: Package Release Assets
shell: bash
working-directory: rust
run: |
mkdir -p release_dist
# Copy the compiled binary
cp target/${{ matrix.target }}/release/${{ matrix.binary }} release_dist/
# Include the installation and management scripts from root
cp ../install.sh release_dist/
# Create compressed archive with custom naming: cortex_version_suffix
if [ "${{ runner.os }}" == "Windows" ]; then
# Windows runner has 7z in path
7z a ../cortex_${{ env.RELEASE_VERSION }}_${{ matrix.suffix }}.zip ./release_dist/*
cp target/${{ matrix.target }}/release/${{ matrix.binary }} ../cortex_${{ env.RELEASE_VERSION }}_${{ matrix.suffix }}.exe
else
tar -czf ../cortex_${{ env.RELEASE_VERSION }}_${{ matrix.suffix }}.tar.gz -C release_dist .
cp target/${{ matrix.target }}/release/${{ matrix.binary }} ../cortex_${{ env.RELEASE_VERSION }}_${{ matrix.suffix }}
fi
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: cortex_${{ env.RELEASE_VERSION }}_${{ matrix.suffix }}
path: cortex_${{ env.RELEASE_VERSION }}_${{ matrix.suffix }}*
publish:
name: Publish GitHub Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Extract Release Notes
id: extract_notes
shell: bash
run: |
# 1. Create a "Quick Install" header with one-liners
cat <<EOF > release_body.md
## 🚀 Quick Install
**Unix (Linux & macOS)**
```bash
curl -sSL https://raw.githubusercontent.com/Dopove/Cortex/main/install.sh | bash
```
**Windows (PowerShell)**
```powershell
irm https://raw.githubusercontent.com/Dopove/Cortex/main/install.ps1 | iex
```
---
EOF
# 2. Extract section between the first and second H1 headers and append
sed -n "/^# Release Notes: Cortex ${{ needs.build.outputs.version }}/,/^# Release Notes:/p" RELEASE_NOTES.md | sed '$d' >> release_body.md
echo "notes_path=release_body.md" >> $GITHUB_OUTPUT
- name: Download All Binaries
uses: actions/download-artifact@v4
with:
path: release_artifacts
merge-multiple: true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: Cortex ${{ needs.build.outputs.version }} Stable Release
tag_name: ${{ needs.build.outputs.version }}
body_path: release_body.md
files: release_artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}