diff --git a/.github/scripts/check-release.sh b/.github/scripts/check-release.sh new file mode 100644 index 00000000..646e9815 --- /dev/null +++ b/.github/scripts/check-release.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Checking if current tag matches the package version +current_tag=$(echo $GITHUB_REF | tr -d 'refs/tags/v') +file_tag=$(grep '"version":' package.json | cut -d ':' -f 2- | tr -d ' ' | tr -d '"' | tr -d ',') +if [ "$current_tag" != "$file_tag" ]; then + echo "Error: the current tag does not match the version in package file(s)." + echo "$current_tag vs $file_tag" + exit 1 +fi + +echo 'OK' +exit 0 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..6dc2bfcf --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,25 @@ +name: Publish to npm +on: + push: + tags: + - v* + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: https://registry.npmjs.org/ + - name: Check release validity + run: sh .github/scripts/check-release.sh + - name: Install dependencies + run: yarn install + - name: Build + run: yarn build + - name: Publish + run: npm publish . + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/README.md b/README.md index dfccf3ee..3ca97b59 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@

+ npm version + Tests + License Slack