Skip to content

Commit

Permalink
Merge pull request #297 from equinor/sefo/feat/add-node-bump-workflow
Browse files Browse the repository at this point in the history
ci: add publish workflow
  • Loading branch information
sefornes authored Jan 22, 2025
2 parents dacb229 + 9feb6b8 commit afce475
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Node CI

on: [push]
on:
push:
branches: [dev]
pull_request:
branches: [dev]
types: closed

jobs:
build:
Expand All @@ -24,3 +29,15 @@ jobs:
npm run lint
env:
CI: true
- name: Compare versions
id: compare
shell: bash
run: |
PKG_VERSION="$(npm search videx-wellog -json true | jq .[].version -r)"
echo "Online version: $PKG_VERSION"
LOCAL_VERSION="$(cat package.json | jq .version -r)"
if ! printf "$LOCAL_VERSION\n$PKG_VERSION" | sort -V -C; then BUMP=true; else BUMP=false; fi;
echo $BUMP >> $GITHUB_OUTPUT
- name: Publish
if: ${{steps.compare.outputs.BUMP == 'true'}} && github.event.pull_request.merged = true
uses: .github/workflows/publish-npm.yml
30 changes: 30 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish to NPM
on:
workflow_call:
inputs:
working_directory:
description: "The working directory to publish from"
required: false
default: "."
type: string
package_name:
description: "The name of the package to publish"
required: true
type: string
secrets:
npm_token:
description: "The NPM token to use for publishing"
required: true

jobs:
publish:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get published package version
shell: bash
run: |
PKG_VERSION="$(npm search videx-wellog -json true | jq .[].version -r)"

0 comments on commit afce475

Please sign in to comment.