Skip to content

Commit a8aaded

Browse files
committed
First version of the GitHub Action
0 parents  commit a8aaded

File tree

5 files changed

+122
-0
lines changed

5 files changed

+122
-0
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
.github

Dockerfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
FROM rust:1.35.0-slim
2+
3+
LABEL name="rust-musl-builder"
4+
LABEL version="1.0.0"
5+
LABEL repository="https://github.com/juankaram/rust-musl-action"
6+
LABEL homepage="https://github.com/juankaram/rust-musl-action"
7+
LABEL maintainer="Juan Karam"
8+
9+
LABEL com.github.actions.name="Rust MUSL Builder"
10+
LABEL com.github.actions.description="Provides a Rust MUSL environment"
11+
LABEL com.github.actions.icon="settings"
12+
LABEL com.github.actions.color="orange"
13+
14+
RUN apt-get update && apt-get install -y zip build-essential musl-tools pkg-config libssl-dev
15+
16+
ENV BUILD_DIR=/build \
17+
OUTPUT_DIR=/output \
18+
RUST_BACKTRACE=1 \
19+
RUSTUP_HOME=/usr/local/rustup \
20+
CARGO_HOME=/usr/local/cargo \
21+
PATH=/usr/local/cargo/bin:$PATH \
22+
PREFIX=/toolchain \
23+
MUSL_VERSION=1.1.22 \
24+
OPENSSL_VERSION=1.1.0k \
25+
BUILD_TARGET=x86_64-unknown-linux-musl
26+
27+
RUN mkdir -p /usr/local/cargo/bin \
28+
&& mkdir -p $BUILD_DIR \
29+
&& mkdir -p $OUTPUT_DIR \
30+
&& mkdir -p $PREFIX
31+
32+
WORKDIR $PREFIX
33+
34+
ADD http://www.musl-libc.org/releases/musl-$MUSL_VERSION.tar.gz .
35+
RUN tar -xvzf musl-$MUSL_VERSION.tar.gz \
36+
&& cd musl-$MUSL_VERSION \
37+
&& ./configure --prefix=$PREFIX \
38+
&& make install \
39+
&& cd ..
40+
41+
ENV CC=$PREFIX/bin/musl-gcc \
42+
C_INCLUDE_PATH=$PREFIX/include/ \
43+
CPPFLAGS=-I$PREFIX/include \
44+
LDFLAGS=-L$PREFIX/lib
45+
46+
ADD https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz .
47+
48+
RUN echo "Building OpenSSL" \
49+
&& tar -xzf "openssl-$OPENSSL_VERSION.tar.gz" \
50+
&& cd openssl-$OPENSSL_VERSION \
51+
&& ./Configure no-async no-afalgeng no-shared no-zlib -fPIC --prefix=$PREFIX --openssldir=$PREFIX/ssl linux-x86_64 \
52+
&& make depend \
53+
&& make install
54+
55+
ENV OPENSSL_DIR=$PREFIX \
56+
OPENSSL_STATIC=true
57+
58+
WORKDIR $BUILD_DIR
59+
60+
RUN rustup self update && rustup update
61+
RUN rustup target add $BUILD_TARGET
62+
RUN rustup component add clippy-preview
63+
RUN rustup component add rustfmt-preview
64+
RUN cargo install cargo-release
65+
66+
COPY entrypoint.sh /entrypoint.sh
67+
ENTRYPOINT ["/entrypoint.sh"]

LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2018 Juan Karam, GitHub, Inc. and contributors
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.
23+

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# GitHub Action for Rust and MUSL
2+
3+
Action provides an environment with Rust, MUSL and x86_64-unknown-linux-musl target.
4+
5+
## Usage
6+
7+
To compile a rust binary/library with x86_64-unknown-linux-musl target:
8+
9+
```hcl
10+
action "build" {
11+
env = {
12+
BUILD_TARGET = "x86_64-unknown-linux-musl"
13+
}
14+
uses = "juankaram/rust-musl-action@master"
15+
args = "cargo build --target $BUILD_TARGET --release"
16+
}
17+
```
18+
19+
## Attribution
20+
21+
Heavily inspired by [GitHub Actions](https://github.com/actions), [Rust Action](https://github.com/icepuma/rust-action) and [David Lewis Work](https://github.com/davidarmstronglewis).
22+
23+
## License
24+
25+
The Dockerfile and associated scripts and documentation in this project are released under the [MIT License](LICENSE).
26+

entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -e -u -o pipefail
3+
cd $GITHUB_WORKSPACE
4+
bash -c "$*"

0 commit comments

Comments
 (0)