@@ -75,33 +75,40 @@ jobs:
75
75
- name : Setup PostgreSQL
76
76
uses : ikalnytskyi/action-setup-postgres@v6
77
77
78
- - id : build
78
+ - id : detect_host
79
79
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 }}
87
88
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
91
101
else
92
- tar cvzf $ASSET_NAME xsnippet-api
102
+ tar cvzf ${{ matrix.name }} xsnippet-api
93
103
fi
94
- gh release upload $RELEASE_TAG $ASSET_NAME
104
+ gh release upload ${{ needs.create_release.outputs.release_tag }} ${{ matrix.name }}
95
105
popd
96
106
97
- echo "asset_path=target/${TARGET} /release/$ASSET_NAME " >> $GITHUB_OUTPUT
107
+ echo "asset_path=target/${{ matrix.target }} /release/${{ matrix.name }} " >> $GITHUB_OUTPUT
98
108
env :
99
- ASSET_NAME : ${{ matrix.name }}
100
109
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
101
110
GH_REPO : ${{ env.GITHUB_REPOSITORY }}
102
- TARGET : ${{ matrix.target }}
103
- RELEASE_TAG : ${{ needs.create_release.outputs.release_tag }}
104
111
105
112
- uses : actions/attest-build-provenance@v1
106
113
with :
107
- subject-path : ${{ steps.build .outputs.asset_path }}
114
+ subject-path : ${{ steps.upload .outputs.asset_path }}
0 commit comments