From 692048d537b1a2d0822124516bfec6a9095575da Mon Sep 17 00:00:00 2001 From: Nugine Date: Mon, 4 Nov 2024 15:06:19 +0800 Subject: [PATCH] ci: improve build workflow (#115) * ci: fix build workflow * ci: use setup actions --- .github/workflows/build.yml | 41 ++++++++++++++++++------------------- .github/workflows/e2e.yml | 39 ++++------------------------------- .github/workflows/rust.yml | 39 ++++------------------------------- 3 files changed, 28 insertions(+), 91 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c75e8f12..d079c01a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,9 +4,12 @@ on: workflow_dispatch: schedule: - cron: '0 0 * * 0' # at midnight of each sunday + push: + branches: + - main jobs: - build: + build-rustfs: runs-on: ubuntu-latest steps: @@ -15,28 +18,24 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - - name: install protoc + - uses: arduino/setup-protoc@v3 + with: + version: "27.0" + + - uses: Nugine/setup-flatc@v1 + with: + version: "24.3.25" + + - name: Build binaries run: | - wget https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip - unzip protoc-27.0-linux-x86_64.zip -d protoc3 - mv protoc3/bin/* /usr/local/bin/ - chmod +x /usr/local/bin/protoc - rm -rf protoc-27.0-linux-x86_64.zip protoc3 + cargo build -p rustfs --bins + cargo build -p rustfs --bins --release - - run: protoc --version - - - name: install flatc - run: | - wget https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.g++-13.zip - unzip Linux.flatc.binary.g++-13.zip - mv flatc /usr/local/bin/ - chmod +x /usr/local/bin/flatc - rm -rf Linux.flatc.binary.g++-13.zip - - - run: flatc --version - - - run: cargo build -p rustfs --bins --release + mkdir -p target/artifacts + mv ./target/debug/rustfs ./target/artifacts/rustfs.debug.x86_64-unknown-linux-gnu + mv ./target/release/rustfs ./target/artifacts/rustfs.release.x86_64-unknown-linux-gnu - uses: actions/upload-artifact@v4 with: - path: ./target/release/rustfs + name: rustfs + path: ./target/artifacts/* diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 57535506..a6f5846a 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -39,44 +39,13 @@ jobs: # - nightly steps: - - name: cache protoc bin - id: cache-protoc-action - uses: actions/cache@v4 - env: - cache-name: cache-protoc-action-bin + - uses: arduino/setup-protoc@v3 with: - path: /usr/local/bin/protoc - key: ${{ runner.os }}-build-${{ env.cache-name }}-v0.0.1 + version: "27.0" - - name: install protoc - if: steps.cache-protoc-action.outputs.cache-hit != 'true' - run: | - wget https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip - unzip protoc-27.0-linux-x86_64.zip -d protoc3 - mv protoc3/bin/* /usr/local/bin/ - chmod +x /usr/local/bin/protoc - rm -rf protoc-27.0-linux-x86_64.zip protoc3 - - - name: print protoc version - run: protoc --version - - - name: cache flatc bin - id: cache-flatc-action - uses: actions/cache@v4 - env: - cache-name: cache-flatc-action-bin + - uses: Nugine/setup-flatc@v1 with: - path: /usr/local/bin/flatc - key: ${{ runner.os }}-build-${{ env.cache-name }}-v0.0.1 - - - name: install flatc - if: steps.cache-flatc-action.outputs.cache-hit != 'true' - run: | - wget https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.g++-13.zip - unzip Linux.flatc.binary.g++-13.zip - mv flatc /usr/local/bin/ - chmod +x /usr/local/bin/flatc - rm -rf Linux.flatc.binary.g++-13.zip + version: "24.3.25" - uses: actions/checkout@v4 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 32fa4463..b2f2eb77 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -38,44 +38,13 @@ jobs: - nightly steps: - - name: cache protoc bin - id: cache-protoc-action - uses: actions/cache@v4 - env: - cache-name: cache-protoc-action-bin + - uses: arduino/setup-protoc@v3 with: - path: /usr/local/bin/protoc - key: ${{ runner.os }}-build-${{ env.cache-name }}-v0.0.1 + version: "27.0" - - name: install protoc - if: steps.cache-protoc-action.outputs.cache-hit != 'true' - run: | - wget https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip - unzip protoc-27.0-linux-x86_64.zip -d protoc3 - mv protoc3/bin/* /usr/local/bin/ - chmod +x /usr/local/bin/protoc - rm -rf protoc-27.0-linux-x86_64.zip protoc3 - - - name: print protoc version - run: protoc --version - - - name: cache flatc bin - id: cache-flatc-action - uses: actions/cache@v4 - env: - cache-name: cache-flatc-action-bin + - uses: Nugine/setup-flatc@v1 with: - path: /usr/local/bin/flatc - key: ${{ runner.os }}-build-${{ env.cache-name }}-v0.0.1 - - - name: install flatc - if: steps.cache-flatc-action.outputs.cache-hit != 'true' - run: | - wget https://github.com/google/flatbuffers/releases/download/v24.3.25/Linux.flatc.binary.g++-13.zip - unzip Linux.flatc.binary.g++-13.zip - mv flatc /usr/local/bin/ - chmod +x /usr/local/bin/flatc - rm -rf Linux.flatc.binary.g++-13.zip + version: "24.3.25" - uses: actions/checkout@v4