diff --git a/.gitignore b/.gitignore index 8b78de8..df03df5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -/target +target* *.env *cache* diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..ca79284 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,20 @@ +pipeline { + agent any + stages { + stage('check deps') { + steps { + sh 'cargo --version' + } + } + stage('compile') { + steps { + sh 'cargo build' + } + } + stage('run with cargo') { + steps { + sh 'cargo run' + } + } + } +} diff --git a/scripts/install.sh b/scripts/install.sh index 964b1ac..8470739 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -21,7 +21,17 @@ error() { main() { BIN_PATH="/usr/local/bin"; BIN_NAME="gptc"; - URL="https://github.com/dmosc/gptc/releases/latest/download/gptc"; + OS=$(uname -s); + ARCH=$(uname -m); + URL="https://github.com/dmosc/gptc/releases/latest/download/gptc-$OS-$ARCH"; + + if [[ $OS != *"Linux"* || $OS != *"Darwin"* || $OS != *"Windows"* ]]; then + error "Unsupported operating system: $OS"; + fi + + if [[ $ARCH != *"x86_64"* || $ARCH != *"arm64"* || $ARCH != *"aarch64"* ]]; then + error "Unsupported architecture: $ARCH"; + fi if [[ $SHELL == *"/zsh" ]]; then SHELL_PROFILE="$HOME/.zshrc"; diff --git a/x86_64-linux.Dockerfile b/x86_64-linux.Dockerfile new file mode 100644 index 0000000..c9affb6 --- /dev/null +++ b/x86_64-linux.Dockerfile @@ -0,0 +1,11 @@ +FROM amd64/rust:latest + +WORKDIR /app +COPY . . +RUN apt update +RUN apt upgrade -y +RUN apt install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev +RUN rm -rf /var/lib/apt/lists/* +RUN cargo install --path . +ENV CARGO_TARGET_DIR=target.x86_64-linux +CMD ["cargo", "build", "--release"] diff --git a/x86_64-windows.Dockerfile b/x86_64-windows.Dockerfile new file mode 100644 index 0000000..dc6adf8 --- /dev/null +++ b/x86_64-windows.Dockerfile @@ -0,0 +1,10 @@ +FROM rust:latest + +WORKDIR /app +RUN apt update +RUN apt upgrade -y +RUN apt install -y g++-mingw-w64-x86-64 +RUN rustup target add x86_64-pc-windows-gnu +RUN rustup toolchain install stable-x86_64-pc-windows-gnu +ENV CARGO_TARGET_DIR=target/target.x86_64-windows +CMD ["cargo", "build", "--release", "--target", "x86_64-pc-windows-gnu"]