Skip to content

Commit

Permalink
Set up for CI build publication through Github Workflows to @dalet-oss
Browse files Browse the repository at this point in the history
…organisation co-ordinates
  • Loading branch information
oliverlockwood committed Oct 18, 2024
1 parent 1468280 commit 3946dac
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 21 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'CI Build'

on:
workflow_dispatch:
push:
branches:
- master
pull_request:
types: [ opened, reopened, edited, synchronize ]
branches:
- master

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: false

jobs:
compile-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
scope: '@dalet-oss'

- name: Install dependencies
run: yarn install

- name: Build
run: yarn build

- name: Run tests
run: yarn test
40 changes: 40 additions & 0 deletions .github/workflows/ci-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'CI Publish to Maven Central'

on:
workflow_dispatch:
push:
tags:
- 'release/*'

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: false

jobs:
compile-test-and-publish-to-npm:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
cache-dependency-path: 'yarn.lock'
scope: '@dalet-oss'

- name: Install dependencies
run: yarn install

- name: Build
run: yarn build

- name: Run tests
run: yarn test

- name: Publish to public NPM registry
run: ./publish.sh
env:
NPM_REGISTRY_ACCESS_TOKEN: ${{ secrets.NPM_REGISTRY_ACCESS_TOKEN }}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
# LexoRank on Typescript
A reference implementation of a list ordering system like [JIRA's Lexorank algorithm](https://www.youtube.com/watch?v=OjQv9xMoFbg).

[![npm version](https://badge.fury.io/js/lexorank.svg)](https://badge.fury.io/js/lexorank)
[![npm version](https://badge.fury.io/js/@dalet-oss%2Flexorank.svg)](https://badge.fury.io/js/@dalet-oss%2Flexorank)

This was forked from [https://github.com/kvandake/lexorank-ts](https://github.com/kvandake/lexorank-ts) in October 2024
because, unfortunately, the maintainer appears to have abandoned their project.

## Getting Started

Npm
```sh
npm install lexorank
npm install @dalet-oss/lexorank
```

Yarn
```sh
yarn add lexorank
yarn add @dalet-oss/lexorank
```

## Storyboard
Expand All @@ -24,7 +27,7 @@ yarn add lexorank


```typescript
import {LexoRank} from "lexorank";
import { LexoRank } from '@dalet-oss/lexorank';

// min
const minLexoRank = LexoRank.min();
Expand All @@ -39,7 +42,7 @@ const parsedLexoRank = LexoRank.parse('0|0i0000:');
### Public methods

```typescript
import {LexoRank} from "lexorank";
import { LexoRank } from '@dalet-oss/lexorank';

// any lexoRank
const lexoRank = LexoRank.middle();
Expand All @@ -58,7 +61,7 @@ const lexoRankStr = lexoRank.toString();

LexRank calculation based on existing LexoRanks.
```typescript
import {LexoRank} from "lexorank";
import { LexoRank } from '@dalet-oss/lexorank';

// any lexorank
const any1LexoRank = LexoRank.min();
Expand Down
27 changes: 12 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"name": "lexorank",
"_id": "[email protected]",
"version": "1.0.5",
"name": "@dalet-oss/lexorank",
"version": "1.0.0-DEV",
"description": "A reference implementation of a list ordering system like JIRA's Lexorank algorithm",
"author": {
"name": "kvandake"
"name": "Oliver Lockwood"
},
"contributors": [
"Oliver Lockwood (@oliverlockwood)",
"Manan Shah (@mananrshah)",
"@kvandake"
],
"license": "MIT",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand All @@ -15,24 +19,17 @@
],
"repository": {
"type": "git",
"url": "git+https://github.com/kvandake/lexorank-ts.git"
"url": "git+https://github.com/dalet-oss/lexorank-ts.git"
},
"bugs": {
"url": "https://github.com/kvandake/lexorank-ts/issues"
"url": "https://github.com/dalet-oss/lexorank-ts/issues"
},
"homepage": "https://github.com/kvandake/lexorank-ts",
"homepage": "https://github.com/dalet-oss/lexorank-ts",
"scripts": {
"clean": "rimraf lib",
"build": "yarn run clean && tsc",
"test": "jest",
"lint": "eslint -c .eslintrc.js --ext .ts ./src",
"prepublishOnly": "yarn test && yarn run lint",
"preversion": "yarn run lint",
"version": "git add -A src",
"postversion": "git push && git push --tags",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"chromatic": "npx chromatic --project-token=$CHROMATIC_PROJECT_TOKEN"
"lint": "eslint -c .eslintrc.js --ext .ts ./src"
},
"devDependencies": {
"@babel/core": "^7.18.13",
Expand Down
36 changes: 36 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
echo 'Determining version number for publication'
echo 'Looking for an existing release tag against this commit'

VERSION=$(git describe --tags --match release/* --exact-match 2>&1)
if [ $? -ne 0 ]
then
LAST=$(git describe --tags --match release/* 2>&1)
if [ $? -ne 0 ]
then
echo 'No release tags found at all; bail out'
exit 1
fi

echo "No matching tag found. Push a tag like release/1.0.1 against HEAD in order to release. Most recent tag is: ${LAST}"
exit 0
fi

VERSION=$(echo $VERSION | sed 's#release/##g')
echo "Publishing version: ${VERSION}"

status=$(curl -s --head -w %{http_code} -o /dev/null https://www.npmjs.com/package/@dalet-oss/lexorank/v/${VERSION}/)
if [ $status -eq 200 ]
then
echo 'Version already available on the NPM Registry. This must be a rebuild; nothing to do here.'
else
echo 'Version not already available on the NPM Registry'

echo 'Setting the version into package.json'
yarn version --no-git-tag-version --new-version ${VERSION}

echo 'Adding NPM registry access token for https://registry.npmjs.org into local .npmrc'
echo "//registry.npmjs.org/:_authToken=${NPM_REGISTRY_ACCESS_TOKEN}" >> .npmrc

echo 'Publishing to NPM Central'
npm publish --access public
fi

0 comments on commit 3946dac

Please sign in to comment.