Skip to content

Commit

Permalink
feat: add npm deployment workflow and update package files
Browse files Browse the repository at this point in the history
  • Loading branch information
isakruas committed Oct 25, 2024
1 parent 174eff6 commit 3010122
Show file tree
Hide file tree
Showing 5 changed files with 519 additions and 75 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/deploy-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Deploy to npm

on:
push:
branches:
- master

jobs:
publish-npm:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: 'https://registry.npmjs.org/'

# Install dependencies
- name: Install dependencies
run: npm install

# Get the short hash of the last commit
- name: Get short commit hash
id: get_hash
run: echo "HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

# Update the version in package.json
- name: Update version
run: |
VERSION="0.0.1-alpha.$HASH"
jq --arg ver "$VERSION" '.version = $ver' package.json > tmp.json && mv tmp.json package.json
# Build the package
- name: Build package
run: npm run build

# Run tests
- name: Run tests
run: npm test

# Publish to npm
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish
31 changes: 31 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Ignore the following common files and directories:

# Node.js modules
node_modules/

# Ignore development files and directories
dist/ # Exclude the build output directory (if not needed)
src/ # Exclude the source files (if only publishing dist)

# Ignore common configuration files
.eslintignore # ESLint ignore file
.eslintrc # ESLint config file
.babelrc # Babel config file
.npmrc # npm config file
.vscode/ # VS Code settings folder
.git/ # Git version control directory

# Ignore testing files and directories
tests/ # Exclude any test directories
test/ # Exclude any test directories
**/*.test.js # Ignore all test files with .test.js extension

# Ignore other common files
*.log # Ignore log files
*.tmp # Ignore temporary files
*.lock # Ignore lock files (except package-lock.json if you want to keep it)
webpack.config.js # Ignore Webpack config (if not needed)
README.md # You might want to include this for documentation

# Ignore specific folders and files as needed
app/ # Exclude the app directory
Loading

0 comments on commit 3010122

Please sign in to comment.