Skip to content

feat: added publish steps #21

feat: added publish steps

feat: added publish steps #21

Workflow file for this run

name: Rust CI/CD Pipeline
on:
push:
pull_request:
types: [opened, reopened]
env:
RUST_BACKTRACE: 1
jobs:
# Job 1: Format Check
format:
name: Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
# Job 2: Lint Check
lint:
name: Lint Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-lint-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
# Job 3: Build
build:
name: Build
needs: [ lint, format ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build project
run: cargo build --verbose --all-features
report:
name: Report
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-report-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Generate report
run: cargo run report
detect-changes:
if: startsWith(github.ref, 'refs/tags/v')
needs: report
runs-on: ubuntu-latest
outputs:
cli_changed: ${{ steps.filter.outputs.cli }}
packages_changed: ${{ steps.filter.outputs.packages }}
md_changed: ${{ steps.filter.outputs.md }}
steps:
- uses: actions/checkout@v4
- name: Detect changed paths
id: changes
uses: dorny/paths-filter@v3
with:
base: "main"
filters: |
cli:
- 'cli/**'
packages:
- 'reader/**'
md:
- 'definitions/**'
publish-ts-reader:
needs: detect-changes
if: startsWith(github.ref, 'refs/tags/v') && needs.detect-changes.outputs.packages_changed == 'true'
defaults:
run:
working-directory: "./reader/ts"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- run: npm version from-git --git-tag-version=false
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
publish-defintions:
needs: detect-changes
if: startsWith(github.ref, 'refs/tags/v') && needs.detect-changes.outputs.md == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
files: |
definitions
generate_release_notes: true
make_latest: true