1212
1313jobs :
1414 build :
15- name : Build ${{ matrix.target }}
15+ name : Build ${{ matrix.target }} (${{ matrix.cpu_version || 'native' }})
1616 runs-on : ${{ matrix.os }}
1717 strategy :
1818 fail-fast : false
1919 matrix :
2020 include :
21+ # --- Linux x86_64 ---
2122 - target : x86_64-unknown-linux-gnu
2223 os : ubuntu-latest
2324 archive : tar.gz
25+ cpu_version : x86-64-v2
26+ rustflags : " -C target-cpu=x86-64-v2"
27+ - target : x86_64-unknown-linux-gnu
28+ os : ubuntu-latest
29+ archive : tar.gz
30+ cpu_version : x86-64-v3
31+ rustflags : " -C target-cpu=x86-64-v3"
32+ - target : x86_64-unknown-linux-gnu
33+ os : ubuntu-latest
34+ archive : tar.gz
35+ cpu_version : x86-64-v4
36+ rustflags : " -C target-cpu=x86-64-v4"
37+
38+ # --- Linux ARM ---
2439 - target : aarch64-unknown-linux-gnu
2540 os : ubuntu-latest
2641 archive : tar.gz
42+
43+ # --- macOS x86_64 ---
2744 - target : x86_64-apple-darwin
2845 os : macos-latest
2946 archive : tar.gz
3047 macos_sign : true
48+ cpu_version : x86-64-v2
49+ rustflags : " -C target-cpu=x86-64-v2"
50+
51+ # --- macOS ARM ---
3152 - target : aarch64-apple-darwin
3253 os : macos-latest
3354 archive : tar.gz
3455 macos_sign : true
56+
57+ # --- Windows x86_64 ---
58+ - target : x86_64-pc-windows-msvc
59+ os : windows-latest
60+ archive : zip
61+ cpu_version : x86-64-v2
62+ rustflags : " -C target-cpu=x86-64-v2"
63+ - target : x86_64-pc-windows-msvc
64+ os : windows-latest
65+ archive : zip
66+ cpu_version : x86-64-v3
67+ rustflags : " -C target-cpu=x86-64-v3"
3568 - target : x86_64-pc-windows-msvc
3669 os : windows-latest
3770 archive : zip
71+ cpu_version : x86-64-v4
72+ rustflags : " -C target-cpu=x86-64-v4"
73+
74+ # --- Windows ARM ---
3875 - target : aarch64-pc-windows-msvc
3976 os : windows-latest
4077 archive : zip
5592
5693 - uses : Swatinem/rust-cache@v2
5794 with :
58- key : ${{ matrix.target }}
95+ # Scopes the cache by CPU version as well so v2, v3, and v4 don't thrash each other's cache
96+ key : ${{ matrix.target }}-${{ matrix.cpu_version || 'default' }}
5997
6098 - name : Build
99+ env :
100+ RUSTFLAGS : ${{ matrix.rustflags || '' }}
101+ CARGO_PROFILE_RELEASE_OPT_LEVEL : " 3"
102+ CARGO_PROFILE_RELEASE_LTO : " fat"
103+ CARGO_PROFILE_RELEASE_CODEGEN_UNITS : " 1"
61104 run : cargo build --release --target ${{ matrix.target }}
62105
63106 # --- macOS: import certificate and sign the binary ---
@@ -68,27 +111,19 @@ jobs:
68111 APPLE_CERTIFICATE : ${{ secrets.APPLE_CERTIFICATE }}
69112 APPLE_CERTIFICATE_PASSWORD : ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
70113 run : |
71- # Write the .p12 to disk
72114 echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12
73-
74- # Create a temporary keychain so we don't touch the login keychain
75115 security create-keychain -p actions-keychain phpantom.keychain
76116 security set-keychain-settings -lut 21600 phpantom.keychain
77117 security unlock-keychain -p actions-keychain phpantom.keychain
78-
79- # Import the certificate + private key
80118 security import certificate.p12 \
81119 -k phpantom.keychain \
82120 -P "$APPLE_CERTIFICATE_PASSWORD" \
83121 -T /usr/bin/codesign
84122 security list-keychain -d user -s phpantom.keychain
85-
86- # Allow codesign to use the key without a UI prompt
87123 security set-key-partition-list \
88124 -S apple-tool:,apple: \
89125 -k actions-keychain \
90126 phpantom.keychain
91-
92127 rm certificate.p12
93128
94129 - name : Sign binary (macOS)
@@ -111,7 +146,6 @@ jobs:
111146 APPLE_ID_PASSWORD : ${{ secrets.APPLE_ID_PASSWORD }}
112147 APPLE_TEAM_ID : ${{ secrets.APPLE_TEAM_ID }}
113148 run : |
114- # Zip just for submission — notarytool requires an archive
115149 ditto -c -k --keepParent \
116150 target/${{ matrix.target }}/release/phpantom_lsp \
117151 phpantom_lsp-notarize.zip
@@ -135,22 +169,25 @@ jobs:
135169 if : matrix.archive == 'tar.gz'
136170 run : |
137171 cd target/${{ matrix.target }}/release
138- tar czf ../../../phpantom_lsp-${{ matrix.target }}.tar.gz phpantom_lsp
172+ # Appends the cpu_version (e.g., -x86-64-v3) to the archive name if it exists
173+ SUFFIX="${{ matrix.cpu_version && format('-{0}', matrix.cpu_version) || '' }}"
174+ tar czf ../../../phpantom_lsp-${{ matrix.target }}${SUFFIX}.tar.gz phpantom_lsp
139175 cd ../../..
140176
141177 - name : Package (windows)
142178 if : matrix.archive == 'zip'
143179 shell : pwsh
144180 run : |
181+ $suffix = "${{ matrix.cpu_version }}" ? "-${{ matrix.cpu_version }}" : ""
145182 Compress-Archive `
146183 -Path "target/${{ matrix.target }}/release/phpantom_lsp.exe" `
147- -DestinationPath "phpantom_lsp-${{ matrix.target }}.zip"
184+ -DestinationPath "phpantom_lsp-${{ matrix.target }}$suffix .zip"
148185
149186 - name : Upload artifact
150187 uses : actions/upload-artifact@v4
151188 with :
152- name : phpantom_lsp-${{ matrix.target }}
153- path : phpantom_lsp-${{ matrix.target }}.${{ matrix.archive }}
189+ name : phpantom_lsp-${{ matrix.target }}-${{ matrix.cpu_version || 'native' }}
190+ path : phpantom_lsp-${{ matrix.target }}${{ matrix.cpu_version && format('-{0}', matrix.cpu_version) || '' }} .${{ matrix.archive }}
154191
155192 release :
156193 name : Create Release
@@ -171,4 +208,4 @@ jobs:
171208 run : |
172209 for file in artifacts/*; do
173210 gh release upload "${{ github.event.release.tag_name }}" "$file" --clobber
174- done
211+ done
0 commit comments