Skip to content

Commit 842c8ca

Browse files
committed
ci: fix build error on windows
See sfackler/rust-openssl#2149. Apparently, in the Windows runner, commands executed in a `run` block will use the version of Perl built into MinGW instead of the one installed in the system, which breaks the openssl build because one of the expected Perl modules can't be found. There are different ways to fix this. The one suggested in this PR is returning back to using the cargo action for "normal" (not cross compilation) builds like it used to work before. My understanding is that it helps by running cargo directly as opposed to running it from Bash. Alternatively, we could bypass the corresponding build steps in openssl by providing locations of openssl source code via environment variables like it is suggested in the rust-openssl issue linked above.
1 parent 8c7f829 commit 842c8ca

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ jobs:
6262
name: xsnippet-api-aarch64-macos.gz
6363

6464
runs-on: ${{ matrix.os }}
65+
env:
66+
ASSET_NAME: ${{ matrix.name }}
67+
TARGET: ${{ matrix.target }}
6568

6669
steps:
6770
- uses: actions/checkout@v4
@@ -75,16 +78,24 @@ jobs:
7578
- name: Setup PostgreSQL
7679
uses: ikalnytskyi/action-setup-postgres@v6
7780

78-
- id: build
81+
- run: |
82+
echo "HOST=$(rustc -vV | grep host: | awk '{print $2}')" >> $GITHUB_ENV
83+
84+
- name: Build
85+
if: ${{ env.HOST == matrix.target }}
86+
uses: actions-rs/cargo@v1
87+
with:
88+
command: build
89+
args: --release
90+
91+
- name: Build (cross-compile)
92+
if: ${{ env.HOST != matrix.target }}
7993
run: |
80-
export HOST=$(rustc -vV | grep host: | awk '{print $2}')
81-
if [ "$HOST" = "$TARGET" ]; then
82-
cargo build --release --target ${TARGET}
83-
else
84-
cargo install cross
85-
cross build --release --target ${TARGET}
86-
fi
94+
cargo install cross
95+
cross build --release --target ${TARGET}
8796
97+
- name: Upload artifacts
98+
run: |
8899
pushd target/${TARGET}/release
89100
if [[ "$TARGET" =~ "windows" ]]; then
90101
7z a $ASSET_NAME xsnippet-api.exe
@@ -94,14 +105,12 @@ jobs:
94105
gh release upload $RELEASE_TAG $ASSET_NAME
95106
popd
96107
97-
echo "asset_path=target/${TARGET}/release/$ASSET_NAME" >> $GITHUB_OUTPUT
108+
echo "ASSET_PATH=target/${TARGET}/release/$ASSET_NAME" >> $GITHUB_ENV
98109
env:
99-
ASSET_NAME: ${{ matrix.name }}
100110
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101111
GH_REPO: ${{ env.GITHUB_REPOSITORY }}
102-
TARGET: ${{ matrix.target }}
103112
RELEASE_TAG: ${{ needs.create_release.outputs.release_tag }}
104113

105114
- uses: actions/attest-build-provenance@v1
106115
with:
107-
subject-path: ${{ steps.build.outputs.asset_path }}
116+
subject-path: ${{ env.ASSET_PATH }}

0 commit comments

Comments
 (0)