Skip to content

Commit bfcdf53

Browse files
committed
Publish to NPM in workflow
1 parent 3284633 commit bfcdf53

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

.github/workflows/main.yml

+28-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,25 @@ jobs:
1212
uses: actions/[email protected]
1313
with:
1414
node-version: '20.x'
15+
registry-url: 'https://registry.npmjs.org'
1516

1617
- name: Install all required dependencies
17-
run: yarn install
18+
run: |
19+
yarn install
20+
sudo apt-get update
21+
sudo apt-get -y install jq
22+
23+
- name: Check package version
24+
run: |
25+
if [ ${{ startsWith(github.ref, 'refs/tags/') }} = true ]; then
26+
VERSION=$(basename ${{ github.ref }})
27+
# Abort if version is not the same as in package.json
28+
PKGVERSION=$(jq -r '.version' package.json)
29+
if [ "$VERSION" != "v$PKGVERSION" ]; then
30+
echo "Version mismatch: tag is ${VERSION}, package.json version is ${PKGVERSION}"
31+
exit 1
32+
fi
33+
fi
1834
1935
- name: Compile a deployable application bundle
2036
run: yarn run prod
@@ -73,3 +89,14 @@ jobs:
7389
curl -s -H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
7490
-X DELETE ${{ steps.version_number.outputs.prev_release }}
7591
if: steps.version_number.outputs.prev_release != ''
92+
93+
94+
- name: Publish to NPM
95+
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
96+
run: |
97+
npm run dist
98+
pushd dist
99+
npm publish
100+
popd
101+
env:
102+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)