Skip to content

Commit

Permalink
feat: add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowballXueQiu committed Aug 30, 2023
1 parent ce87651 commit 47cd01b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 15 deletions.
56 changes: 42 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,63 @@
name: Build Server
name: Backend Server CI

on:
release:
types: [created]
types: [ created ]

env:
CARGO_TERM_COLOR: always
PACKAGE_FILE: ${{ needs.create-nightly-release.outputs.package_prefix }}-${{ matrix.build_name }}.${{ startsWith(matrix.build_name, 'win') && 'zip' || 'tar.gz' }}
CARGO_BUILD_DIR: target


jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust:
- beta
include:
- build_name: linux-x86_64
os: ubuntu-22.04

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

- uses: actions-rs/toolchain@v1
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
toolchain: nightly
targets: ${{ matrix.target }}
components: rustfmt, clippy

- uses: actions-rs/cargo@v1
- name: Install Linux dependencies
run: |
sudo apt-get update
- name: Cargo build
run: cargo build --release

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
command: build
args: --release --package rust_server --bin rust_server
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: actions-rs/cargo@v1
- name: Build Image and Push to DockerHub
id: docker_build
uses: docker/build-push-action@v4
with:
command: test
context: ${{ env.CARGO_BUILD_DIR }}
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/backend-server:${{ github.ref_name }}
${{ secrets.DOCKERHUB_USERNAME }}/backend-server:latest
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# .GitHub/workflows/release.yml

name: Backend Docker Image CI

on:
release:
types: [created]
Expand Down
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM rust:latest as build

# 设置工作路径
WORKDIR /app

# 将你的 Rust 项目文件(Cargo.toml 和 src 目录)复制到镜像中
COPY ./Cargo.toml ./Cargo.toml
COPY ./src ./src

# 构建 Rust 项目
RUN cargo build --release

# 创建最终的生产镜像
FROM ubuntu:22.04

USER root

# 复制编译好的二进制文件到最终镜像中
COPY --from=build /app/target/release/BackendServer /home/BackendServer

# 设置运行命令
CMD ["./BackendServer"]
2 changes: 1 addition & 1 deletion src/user/xbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct PreAuthResponse {
pub cookies: HashMap<String, Vec<String>>,
}

//TODO: wait for Microsoft Minecraft's application.
// TODO: wait for Microsoft Minecraft's application.

// pub async fn pre_auth() -> Result<PreAuthResponse, String> {
// let https = HttpsConnector::new();
Expand Down

0 comments on commit 47cd01b

Please sign in to comment.