Skip to content

testing #1

testing #1 #1

Workflow file for this run

name: Publish to npm
on:
push:
branches:
- main
permissions:
packages: write
contents: write
jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
steps:
- name: Install Rust
- uses: hecrj/setup-rust-action@v2
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.OS }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.OS }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache npm cache
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Authenticate with npm
run: npm authenticate
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Get package version
id: package-version
run: echo ::set-output name=version::$(cargo metadata --no-deps --format-version 1 | awk '$1 == "\"version\"" { gsub(/^"|"$/, "", $2); print $2 }')
- name: Build package
run: cargo build --release
- name: Publish to npm
run: cargo npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package-version.outputs.version }}
release_name: Release v${{ steps.package-version.outputs.version }}
draft: false
prerelease: false