Skip to content

Commit

Permalink
ci: add rust publish stage
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Thomas committed Dec 30, 2024
1 parent eb4412b commit 7971375
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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";
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7971375

Please sign in to comment.