Skip to content

Commit 21d558c

Browse files
authored
Add CI to publish to npm (#7)
* Add CI to publish to npm * Add badge
1 parent 8dbf008 commit 21d558c

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

.github/scripts/check-release.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# Checking if current tag matches the package version
4+
current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v')
5+
file_tag=$(grep '"version":' package.json | cut -d ':' -f 2- | tr -d ' ' | tr -d '"' | tr -d ',')
6+
if [ "$current_tag" != "$file_tag" ]; then
7+
echo "Error: the current tag does not match the version in package file(s)."
8+
echo "$current_tag vs $file_tag"
9+
exit 1
10+
fi
11+
12+
echo 'OK'
13+
exit 0

.github/workflows/publish.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish to npm
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
7+
jobs:
8+
publish-npm:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-node@v1
13+
with:
14+
node-version: 12
15+
registry-url: https://registry.npmjs.org/
16+
- name: Check release validity
17+
run: sh .github/scripts/check-release.sh
18+
- name: Install dependencies
19+
run: yarn install
20+
- name: Build
21+
run: yarn build
22+
- name: Publish
23+
run: npm publish .
24+
env:
25+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
</h4>
1515

1616
<p align="center">
17+
<a href="https://www.npmjs.com/package/@meilisearch/instant-meilisearch"><img src="https://img.shields.io/npm/v/@meilisearch/instant-meilisearch.svg" alt="npm version"></a>
18+
<a href="https://github.com/meilisearch/instant-meilisearch/actions"><img src="https://github.com/meilisearch/instant-meilisearch/workflows/Tests/badge.svg?branch=master" alt="Tests"></a>
19+
<a href="https://github.com/meilisearch/instant-meilisearch/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
1720
<a href="https://slack.meilisearch.com"><img src="https://img.shields.io/badge/slack-MeiliSearch-blue.svg?logo=slack" alt="Slack"></a>
1821
<a href="https://github.com/meilisearch/MeiliSearch/discussions" alt="Discussions"><img src="https://img.shields.io/badge/github-discussions-red" /></a>
1922
</p>

0 commit comments

Comments
 (0)