From 79713758cb350decb3b7bc8a8d06db141b298362 Mon Sep 17 00:00:00 2001 From: Michael Thomas Date: Mon, 30 Dec 2024 18:12:51 -0500 Subject: [PATCH] ci: add rust publish stage --- .github/workflows/CI.yml | 35 ++++++++++++++++++++++++++++++++--- .github/workflows/rust.yml | 17 +++++++---------- 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8909e0c..4a460e0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -96,8 +96,35 @@ jobs: name: bindings-${{ matrix.settings.target }} path: "./packages/critters/dist/*.node" if-no-files-found: error - publish: - name: Publish + + publish-rust: + name: Publish to Crates.io + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + env: + CARGO_TERM_COLOR: always + steps: + - uses: actions/checkout@v4 + - name: Setup Rust Toolchain + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + + - name: Test build + run: cargo build --release --verbose + - name: Run tests + run: cargo test --verbose + - name: Rust publish + run: | + if git log -1 --pretty=%B | grep "release main"; + then + cargo publish --token ${CRATES_TOKEN} + fi + env: + CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }} + + publish-npm: + name: Publish to NPM runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' needs: @@ -115,6 +142,8 @@ jobs: uses: dtolnay/rust-toolchain@stable with: toolchain: stable + + # NPM Publish - name: Install dependencies run: pnpm install - name: Download all artifacts @@ -132,7 +161,7 @@ jobs: run: pnpm build - name: View Git Changes run: git status - - name: Publish + - name: Publish NPM run: | npm config set provenance true if git log -1 --pretty=%B | grep "release main"; diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9fd45e0..f4cd6b7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,22 +1,19 @@ -name: Rust +name: Rust PR on: - push: - branches: [ "main" ] pull_request: - branches: [ "main" ] + branches: ["main"] env: CARGO_TERM_COLOR: always jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - uses: actions/checkout@v4 + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose