Skip to content

Commit b8363ad

Browse files
committed
Update publish CI to take release type into account
1 parent db0b14c commit b8363ad

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

.github/scripts/check-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
# Checking if current tag matches the package version
4-
current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v')
4+
current_tag=$(echo $GITHUB_REF | cut -d '/' -f 3 | tr -d ' ')
55
file_tag=$(grep '"version":' package.json | cut -d ':' -f 2- | tr -d ' ' | tr -d '"' | tr -d ',')
66
if [ "$current_tag" != "$file_tag" ]; then
77
echo "Error: the current tag does not match the version in package file(s)."

.github/workflows/publish.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: publish to npm
22
on:
3-
push:
4-
tags:
5-
- v*
3+
release:
4+
types: [published]
65

76
jobs:
87
publish-npm:
@@ -13,13 +12,19 @@ jobs:
1312
with:
1413
node-version: 12
1514
registry-url: https://registry.npmjs.org/
15+
- name: Check release validity
16+
run: sh .github/scripts/check-release.sh
1617
- name: Install dependencies
1718
run: yarn install
18-
- name: Build
19+
- name: Build meilisearch-js
1920
run: yarn build
20-
- name: Check release validity
21-
run: sh .github/scripts/check-release.sh
22-
- name: Publish
21+
- name: Publish with latest tag
22+
if: "github.event.release.release"
2323
run: npm publish .
2424
env:
2525
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
26+
- name: Publish with beta tag
27+
if: "github.event.release.prerelease"
28+
run: npm publish . --tag beta
29+
env:
30+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

0 commit comments

Comments
 (0)