Skip to content

Commit b2291b3

Browse files
committed
fix: fix ci pipeline
1 parent 4dd4884 commit b2291b3

File tree

3 files changed

+90
-31
lines changed

3 files changed

+90
-31
lines changed
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: "Build Binaries"
2+
description: "Build binaries for all supported platforms"
3+
inputs:
4+
package:
5+
description: "Whether to package the binaries into archives"
6+
required: false
7+
default: "false"
8+
publish:
9+
description: "Whether to publish the binaries"
10+
required: false
11+
default: "false"
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
17+
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # ratchet:Swatinem/rust-cache@v2
18+
- name: Install musl-tools on Linux
19+
if: contains(matrix.platform.name, 'musl')
20+
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
21+
shell: bash
22+
- name: Install musl distribution
23+
if: contains(matrix.platform.name, 'musl')
24+
run: rustup target add x86_64-unknown-linux-musl
25+
shell: bash
26+
- name: Build binary
27+
uses: houseabsolute/actions-rust-cross@f7da4010930154943c99d13df0151dece91a924f # ratchet:houseabsolute/actions-rust-cross@v1
28+
with:
29+
command: build
30+
target: ${{ matrix.platform.target }}
31+
toolchain: stable
32+
args: --locked --release --bin sqruff --package sqruff
33+
strip: true
34+
- name: Package as archive
35+
if: inputs.package == 'true'
36+
shell: bash
37+
run: |
38+
cd target/${{ matrix.platform.target }}/release
39+
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
40+
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
41+
else
42+
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
43+
fi
44+
cd -
45+
- name: Generate SHA-256 and Save to File
46+
if: inputs.package == 'true'
47+
run: shasum -a 256 ${{ matrix.platform.name }} > ${{ matrix.platform.name }}.sha256
48+
shell: bash
49+
- name: Generate artifact attestation
50+
if: inputs.publish == 'true'
51+
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # ratchet:actions/attest-build-provenance@v2
52+
with:
53+
subject-path: "sqruff-*"

.github/workflows/pr.yml

+34
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,37 @@ jobs:
179179
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
180180
- run: chmod +x ./.hacking/scripts/check_for_unparsable.sh
181181
- run: ./.hacking/scripts/check_for_unparsable.sh
182+
183+
build-binaries:
184+
name: Build binaries for all platforms
185+
runs-on: ${{ matrix.platform.os }}
186+
strategy:
187+
fail-fast: false
188+
matrix:
189+
platform:
190+
- name: sqruff-linux-x86_64-musl.tar.gz
191+
os: ubuntu-latest
192+
target: x86_64-unknown-linux-musl
193+
bin: sqruff
194+
- name: sqruff-linux-aarch64-musl.tar.gz
195+
os: ubuntu-latest
196+
target: aarch64-unknown-linux-musl
197+
bin: sqruff
198+
- name: sqruff-windows-x86_64.zip
199+
os: windows-latest
200+
target: x86_64-pc-windows-msvc
201+
bin: sqruff.exe
202+
- name: sqruff-darwin-x86_64.tar.gz
203+
os: macos-13
204+
target: x86_64-apple-darwin
205+
bin: sqruff
206+
- name: sqruff-darwin-aarch64.tar.gz
207+
os: macOS-latest
208+
target: aarch64-apple-darwin
209+
bin: sqruff
210+
steps:
211+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
212+
- uses: ./.github/actions/build-binaries
213+
with:
214+
package: false
215+
publish: false

.github/workflows/release.yml

+3-31
Original file line numberDiff line numberDiff line change
@@ -110,37 +110,10 @@ jobs:
110110
bin: sqruff
111111
steps:
112112
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # ratchet:actions/checkout@v4
113-
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # ratchet:Swatinem/rust-cache@v2
114-
- name: Install musl-tools on Linux
115-
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
116-
if: contains(matrix.platform.name, 'musl')
117-
- name: Build binary
118-
uses: houseabsolute/actions-rust-cross@f7da4010930154943c99d13df0151dece91a924f # ratchet:houseabsolute/actions-rust-cross@v1
119-
with:
120-
command: build
121-
target: ${{ matrix.platform.target }}
122-
toolchain: stable
123-
args: --locked --release
124-
strip: true
125-
- name: Package as archive
126-
shell: bash
127-
run: |
128-
cd target/${{ matrix.platform.target }}/release
129-
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
130-
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
131-
else
132-
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
133-
fi
134-
cd -
135-
136-
- name: Generate SHA-256 and Save to File
137-
run: shasum -a 256 ${{ matrix.platform.name }} > ${{ matrix.platform.name }}.sha256
138-
139-
- name: Generate artifact attestation
140-
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # ratchet:actions/attest-build-provenance@v2
113+
- uses: ./.github/actions/build-binaries
141114
with:
142-
subject-path: "sqruff-*"
143-
115+
package: true
116+
publish: true
144117
- name: Publish GitHub release
145118
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # ratchet:ncipollo/release-action@v1
146119
with:
@@ -253,4 +226,3 @@ jobs:
253226
- run: vsce publish --packagePath extension.vsix
254227
env:
255228
VSCE_PAT: ${{ secrets.VSCE_PAT }} # Set up the VSCE Personal Access Token in GitHub secrets
256-

0 commit comments

Comments
 (0)