Skip to content

Commit 3dc6e4a

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 3dc6e4a

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

.github/workflows/release.yml

+25-18
Original file line numberDiff line numberDiff line change
@@ -75,33 +75,40 @@ jobs:
7575
- name: Setup PostgreSQL
7676
uses: ikalnytskyi/action-setup-postgres@v6
7777

78-
- id: build
78+
- id: detect_host
7979
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
80+
echo "host=$(rustc -vV | grep host: | awk '{print $2}')" >> $GITHUB_OUTPUT
81+
82+
- name: Build
83+
if: ${{ steps.detect_host.outputs.host == matrix.target }}
84+
uses: actions-rs/cargo@v1
85+
with:
86+
command: build
87+
args: --release --target ${{ matrix.target }}
8788

88-
pushd target/${TARGET}/release
89-
if [[ "$TARGET" =~ "windows" ]]; then
90-
7z a $ASSET_NAME xsnippet-api.exe
89+
- name: Build (cross-compile)
90+
if: ${{ steps.detect_host.outputs.host != matrix.target }}
91+
run: |
92+
cargo install cross
93+
cross build --release --target ${{ matrix.target }}
94+
95+
- id: upload
96+
name: Upload artifacts
97+
run: |
98+
pushd target/${{ matrix.target }}/release
99+
if [[ "${{ matrix.target }}" =~ "windows" ]]; then
100+
7z a ${{ matrix.name }} xsnippet-api.exe
91101
else
92-
tar cvzf $ASSET_NAME xsnippet-api
102+
tar cvzf ${{ matrix.name }} xsnippet-api
93103
fi
94-
gh release upload $RELEASE_TAG $ASSET_NAME
104+
gh release upload ${{ needs.create_release.outputs.release_tag }} ${{ matrix.name }}
95105
popd
96106
97-
echo "asset_path=target/${TARGET}/release/$ASSET_NAME" >> $GITHUB_OUTPUT
107+
echo "asset_path=target/${{ matrix.target }}/release/${{ matrix.name }}" >> $GITHUB_OUTPUT
98108
env:
99-
ASSET_NAME: ${{ matrix.name }}
100109
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101110
GH_REPO: ${{ env.GITHUB_REPOSITORY }}
102-
TARGET: ${{ matrix.target }}
103-
RELEASE_TAG: ${{ needs.create_release.outputs.release_tag }}
104111

105112
- uses: actions/attest-build-provenance@v1
106113
with:
107-
subject-path: ${{ steps.build.outputs.asset_path }}
114+
subject-path: ${{ steps.upload.outputs.asset_path }}

0 commit comments

Comments
 (0)