1- name : Build and Release  
1+ name : Build and release   
22
33on :
44  workflow_dispatch :
1010      tag_name : 
1111        required : true 
1212        type : string 
13-         default : latest 
13+         default : 
1414      targets :
1515        description : ' JSON array of target platforms to build [{"os": "ubuntu-latest", "target": "x86_64-unknown-linux-gnu"}, ...]' 
1616        required : true 
17-         default : ' [{"os": "ubuntu-latest", "target": "x86_64-unknown-linux-gnu"}, {"os": "ubuntu-latest", "target": "aarch64-unknown-linux-gnu"}, {"os": "windows-latest", "target": "x86_64-pc-windows-msvc"}, {"os": " macos-latest", "target": "x86_64-apple-darwin"}]' 
17+         default : ' [{"os": "ubuntu-latest", "target": "x86_64-unknown-linux-gnu"}, {"os": "ubuntu-latest", "target": "aarch64-unknown-linux-gnu"}, {"os": "macos-latest", "target": "x86_64-apple-darwin"}]' 
1818
1919jobs :
2020  build :
3232        with :
3333          ref : ${{ inputs.branch }} 
3434
35-       - name : Set up Rust toolchain 
36-         uses : dtolnay/rust-toolchain@stable 
37- 
38-       - name : Install target 
39-         run : rustup target add ${{ matrix.target }} 
40- 
41-       - name : Build binary 
42-         run : cargo build --release --target=${{ matrix.target }} 
43- 
44-       - name : Create release artifact 
45-         run : | 
46-           mkdir -p artifacts 
47-           cp target/${{ matrix.target }}/release/dt-main artifacts/ape-dts 
48- 
4935      - name : Create Release 
5036        id : create_release 
5137        uses : softprops/action-gh-release@v1 
@@ -56,11 +42,38 @@ jobs:
5642env :
5743          GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
5844
45+       - name : Set up Rust toolchain 
46+         uses : dtolnay/rust-toolchain@stable 
47+ 
48+       #  Build linux targets by cross, otherwise there may be runtime errors when running on other linux versions:
49+       #  ./ape-dts: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.38' not found (required by ./ape-dts)
50+       #  ./ape-dts: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by ./ape-dts)
51+       - name : Cross build 
52+         if : matrix.target == 'x86_64-unknown-linux-gnu' || matrix.target == 'aarch64-unknown-linux-gnu' || matrix.target == 'x86_64-pc-windows-gnu' 
53+         run : | 
54+           cargo install cross 
55+           cross build --release --target=${{ matrix.target }} 
56+ 
57+       - name : Local build 
58+         if : matrix.target == 'x86_64-apple-darwin' 
59+         run : | 
60+           rustup target add ${{ matrix.target }} 
61+           cargo build --release --target=${{ matrix.target }} 
62+ 
63+ name : Create release artifact 
64+         run : | 
65+           mkdir -p artifacts 
66+           cp target/${{ matrix.target }}/release/dt-main artifacts/ape-dts 
67+           cp log4rs.yaml artifacts/log4rs.yaml 
68+           tar -czvf ape-dts-${{ github.run_id }}-${{ matrix.target }}.tar.gz -C artifacts . 
69+ 
5970name : Upload Release Asset 
6071        id : upload_release_asset 
6172        uses : actions/upload-release-asset@v1 
6273        with :
6374          upload_url : ${{ steps.create_release.outputs.upload_url }} 
64-           asset_path : artifacts/ape-dts 
65-           asset_name : ape-dts-${{ github.run_id }}-${{ matrix.target }} 
66-           asset_content_type : application/octet-stream 
75+           asset_path : ape-dts-${{ github.run_id }}-${{ matrix.target }}.tar.gz 
76+           asset_name : ape-dts-${{ github.run_id }}-${{ matrix.target }}.tar.gz 
77+           asset_content_type : application/gzip 
78+         env :
79+           GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
0 commit comments