Skip to content

Commit 29825cd

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 29825cd

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

.github/workflows/release.yml

+24-18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Build and Release
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ master, release ]
66
tags:
77
- "v*"
88

@@ -75,33 +75,39 @@ jobs:
7575
- name: Setup PostgreSQL
7676
uses: ikalnytskyi/action-setup-postgres@v6
7777

78-
- id: build
78+
- run: |
79+
echo "HOST=$(rustc -vV | grep host: | awk '{print $2}')" >> $GITHUB_ENV
80+
81+
- name: Build
82+
if: ${{ env.HOST == matrix.target }}
83+
uses: actions-rs/cargo@v1
84+
with:
85+
command: build
86+
args: --release
87+
88+
- name: Build (cross-compile)
89+
if: ${{ env.HOST != matrix.target }}
7990
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
91+
cargo install cross
92+
cross build --release --target ${{ matrix.target }}
8793
88-
pushd target/${TARGET}/release
89-
if [[ "$TARGET" =~ "windows" ]]; then
90-
7z a $ASSET_NAME xsnippet-api.exe
94+
- name: Upload artifacts
95+
run: |
96+
pushd target/${{ matrix.target }}/release
97+
if [[ "${{ matrix.target }}" =~ "windows" ]]; then
98+
7z a ${{ matrix.name }} xsnippet-api.exe
9199
else
92-
tar cvzf $ASSET_NAME xsnippet-api
100+
tar cvzf ${{ matrix.name }} xsnippet-api
93101
fi
94-
gh release upload $RELEASE_TAG $ASSET_NAME
102+
gh release upload $RELEASE_TAG ${{ matrix.name }}
95103
popd
96104
97-
echo "asset_path=target/${TARGET}/release/$ASSET_NAME" >> $GITHUB_OUTPUT
105+
echo "ASSET_PATH=target/${{ matrix.target }}/release/${{ matrix.name }}" >> $GITHUB_ENV
98106
env:
99-
ASSET_NAME: ${{ matrix.name }}
100107
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101108
GH_REPO: ${{ env.GITHUB_REPOSITORY }}
102-
TARGET: ${{ matrix.target }}
103109
RELEASE_TAG: ${{ needs.create_release.outputs.release_tag }}
104110

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

0 commit comments

Comments
 (0)