diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..618d557 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,49 @@ +name: Build packages + +on: + push: + +jobs: + rubygems: + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + working-directory: build/ruby + + steps: + # Set up + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2.2' + - name: Install gems + run: bundle install + - name: Generate ruby + run: bundle exec rake generate_ruby:all + - name: Run tests + run: bundle exec rspec + + crates: + runs-on: ubuntu-latest + + defaults: + run: + shell: bash + working-directory: build/rust + + steps: + # Set up + - uses: actions/checkout@v4 + - name: Setup rust + run: rustup update --no-self-update stable + - name: Install protoc + run: curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v28.0-rc1/protoc-28.0-rc-1-linux-x86_64.zip && unzip protoc-28.0-rc-1-linux-x86_64.zip -d ${{ runner.temp }}/proto && chmod +x ${{ runner.temp }}/proto/bin/protoc && ${{ runner.temp }}/proto/bin/protoc --version + - name: Build crate + run: PATH=${{ runner.temp }}/proto/bin:$PATH cargo build + env: + RUST_BACKTRACE: 'full' + - name: Package crate + run: cargo package --allow-dirty diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae64016..cb564df 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -39,3 +39,32 @@ jobs: run: bundle exec rake release:rubygem_push - name: Wait for release run: gem exec rubygems-await pkg/*.gem + crates: + runs-on: ubuntu-latest + + environment: packages + + defaults: + run: + shell: bash + working-directory: build/rust + + steps: + # Set up + - uses: actions/checkout@v4 + - name: Setup rust + run: rustup update --no-self-update stable + - name: Install protoc + run: curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v28.0-rc1/protoc-28.0-rc-1-linux-x86_64.zip && unzip protoc-28.0-rc-1-linux-x86_64.zip -d ${{ runner.temp }}/proto && chmod +x ${{ runner.temp }}/proto/bin/protoc && ${{ runner.temp }}/proto/bin/protoc --version + - name: Set version + run: sed -i "s/version = \"0.0.0\"/version = \"${{ github.ref_name }}\"/" Cargo.toml + - name: Cargo Login + run: cargo login ${{secrets.CARGO_REGISTRY_TOKEN}} + - name: Build crate + run: PATH=${{ runner.temp }}/proto/bin:$PATH cargo build + env: + RUST_BACKTRACE: 'full' + + # Release + - name: Publish crate + run: cargo publish --allow-dirty diff --git a/build/rust/Cargo.lock b/build/rust/Cargo.lock index ee7efc6..baa9c6a 100644 --- a/build/rust/Cargo.lock +++ b/build/rust/Cargo.lock @@ -1055,7 +1055,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tucana-internal" -version = "0.0.1" +version = "0.0.0" dependencies = [ "prost", "prost-serde-derive", diff --git a/build/rust/Cargo.toml b/build/rust/Cargo.toml index b9080be..39cf4fc 100644 --- a/build/rust/Cargo.toml +++ b/build/rust/Cargo.toml @@ -1,5 +1,5 @@ [package] -version = "0.0.1" +version = "0.0.0" name = "tucana-internal" edition = "2021" description = "The rust crate for the internal gRPC communication of Code0" diff --git a/build/rust/build.rs b/build/rust/build.rs index f57e9ad..0316276 100644 --- a/build/rust/build.rs +++ b/build/rust/build.rs @@ -1,8 +1,16 @@ +use std::fs::create_dir; use std::io::Result; fn main() -> Result<()> { + + let path = "src/internal"; + + if !std::path::Path::new(&path).exists() { + create_dir(path)?; + } + tonic_build::configure() - .out_dir("src/internal") + .out_dir(path) .build_server(true) .build_client(true) .type_attribute("Variable", "#[derive(serde::Serialize, serde::Deserialize)]")