@@ -54,135 +54,40 @@ jobs:
5454 - name : Checkout code
5555 uses : actions/checkout@v3
5656
57- - uses : actions/cache@v3
58- with :
59- path : |
60- ~/.cargo/bin/
61- ~/.cargo/registry/index/
62- ~/.cargo/registry/cache/
63- ~/.cargo/git/db/
64- key : ${{ matrix.job.os }}-${{ matrix.job.target }}-cargo-
65-
66- - name : Install prerequisites
57+ - name : Extract project version
6758 shell : bash
6859 run : |
69- case ${{ matrix.job.target }} in
70- arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
71- aarch64-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
72- esac
73-
74- - name : Extract crate information
75- shell : bash
76- run : |
77- echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> $GITHUB_ENV
7860 # Get the project version from mix.exs
79- echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' ../../ mix.exs | head -n1)" >> $GITHUB_ENV
61+ echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV
8062
8163 - name : Install Rust toolchain
8264 uses : actions-rs/toolchain@v1
8365 with :
8466 toolchain : stable
8567 target : ${{ matrix.job.target }}
86- override : true
87- profile : minimal
88-
89- - name : Show version information (Rust, cargo, GCC)
90- shell : bash
91- run : |
92- gcc --version || true
93- rustup -V
94- rustup toolchain list
95- rustup default
96- cargo -V
97- rustc -V
98- rustc --print=cfg
9968
100- - name : Download cross from GitHub releases
101- uses : giantswarm/install-binary-action@v1.0.0
102- if : ${{ matrix.job.use-cross && matrix.job.target != 'aarch64-unknown-linux-musl' }}
69+ - name : Build the project
70+ id : build-crate
71+ uses : philss/rustler-precompiled-action@v1.0.1
10372 with :
104- binary : " cross"
105- version : " v0.2.1"
106- download_url : " https://github.com/rust-embedded/cross/releases/download/${version}/cross-${version}-x86_64-unknown-linux-gnu.tar.gz"
107- tarball_binary_path : " ${binary}"
108- smoke_test : " ${binary} --version"
109-
110- - name : Install cross from GitHub
111- if : ${{ matrix.job.use-cross && matrix.job.target == 'aarch64-unknown-linux-musl' }}
112- shell : bash
113- run : |
114- cargo install --git https://github.com/cross-rs/cross --rev 4deac830a4992a70f7cb070eda38d5ff7cfcbf86 || echo 'Already installed'
115-
116- - name : Build
117- shell : bash
118- run : |
119- if [ "${{ matrix.job.use-cross }}" == "true" ]; then
120- cross build --release --target=${{ matrix.job.target }}
121- else
122- cargo build --release --target=${{ matrix.job.target }}
123- fi
124-
125- - name : Rename lib to the final name
126- id : rename
127- shell : bash
128- run : |
129- LIB_PREFIX="lib"
130- case ${{ matrix.job.target }} in
131- *-pc-windows-*) LIB_PREFIX="" ;;
132- esac;
133-
134- # Figure out suffix of lib
135- # See: https://doc.rust-lang.org/reference/linkage.html
136- LIB_SUFFIX=".so"
137- case ${{ matrix.job.target }} in
138- *-apple-darwin) LIB_SUFFIX=".dylib" ;;
139- *-pc-windows-*) LIB_SUFFIX=".dll" ;;
140- esac;
141-
142- CICD_INTERMEDIATES_DIR=$(mktemp -d)
143-
144- # Setup paths
145- LIB_DIR="${CICD_INTERMEDIATES_DIR}/released-lib"
146- mkdir -p "${LIB_DIR}"
147- LIB_NAME="${LIB_PREFIX}${{ env.PROJECT_NAME }}${LIB_SUFFIX}"
148- LIB_PATH="${LIB_DIR}/${LIB_NAME}"
149-
150- # Copy the release build lib to the result location
151- cp "target/${{ matrix.job.target }}/release/${LIB_NAME}" "${LIB_DIR}"
152-
153- # Final paths
154- # In the end we use ".so" for MacOS in the final build
155- # See: https://www.erlang.org/doc/man/erlang.html#load_nif/2
156- LIB_FINAL_SUFFIX="${LIB_SUFFIX}"
157- case ${{ matrix.job.target }} in
158- *-apple-darwin) LIB_FINAL_SUFFIX=".so" ;;
159- esac;
160-
161- LIB_FINAL_NAME="${LIB_PREFIX}${PROJECT_NAME}-v${PROJECT_VERSION}-nif-${RUSTLER_NIF_VERSION}-${{ matrix.job.target }}${LIB_FINAL_SUFFIX}"
162-
163- # Copy lib to final name on this directory
164- cp "${LIB_PATH}" "${LIB_FINAL_NAME}"
165-
166- tar -cvzf "${LIB_FINAL_NAME}.tar.gz" "${LIB_FINAL_NAME}"
167-
168- # Passes the path relative to the root of the project.
169- LIB_FINAL_PATH="${NIF_DIR}/${LIB_FINAL_NAME}.tar.gz"
170-
171- # Let subsequent steps know where to find the lib
172- echo ::set-output name=LIB_FINAL_PATH::${LIB_FINAL_PATH}
173- echo ::set-output name=LIB_FINAL_NAME::${LIB_FINAL_NAME}.tar.gz
73+ project-name : ex_srtp
74+ project-version : ${{ env.PROJECT_VERSION }}
75+ target : ${{ matrix.job.target }}
76+ nif-version : ${{ matrix.nif }}
77+ use-cross : ${{ matrix.job.use-cross }}
78+ project-dir : ${{ env.NIF_DIR }}
17479
175- - name : " Artifact upload"
80+ - name : Artifact upload
17681 uses : actions/upload-artifact@v3
17782 with :
178- name : ${{ steps.rename .outputs.LIB_FINAL_NAME }}
179- path : ${{ steps.rename .outputs.LIB_FINAL_PATH }}
83+ name : ${{ steps.build-crate .outputs.file-name }}
84+ path : ${{ steps.build-crate .outputs.file-path }}
18085
18186 - name : Publish archives and packages
18287 uses : softprops/action-gh-release@v1
18388 with :
18489 draft : true
18590 generate_release_notes : true
18691 files : |
187- ${{ steps.rename .outputs.LIB_FINAL_PATH }}
92+ ${{ steps.build-crate .outputs.file-path }}
18893 if : startsWith(github.ref, 'refs/tags/')
0 commit comments