Skip to content

Commit ca5fc63

Browse files
authored
Chore: automatically publish the npm package when the version is updated (#28)
1 parent ddfb12a commit ca5fc63

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

.github/workflows/npm-publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: NPM Package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish-npm:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
17+
- run: npm install
18+
19+
- name: Extract version
20+
id: version
21+
run: |
22+
OLD_VERSION=$(npm show @gnosis.pm/safe-react-gateway-sdk version)
23+
NEW_VERSION=$(node -p 'require("./package.json").version')
24+
if [ $NEW_VERSION != $OLD_VERSION ]; then
25+
echo "New version $NEW_VERSION detected"
26+
echo "::set-output name=version::v$NEW_VERSION"
27+
git log "v$OLD_VERSION"..HEAD --pretty=format:"* %s" > CHANGELOG.md
28+
else
29+
echo "Version $OLD_VERSION hasn't changed, skipping the release"
30+
exit 1
31+
fi
32+
33+
- name: Publish to NPM
34+
uses: JS-DevTools/npm-publish@v1
35+
with:
36+
token: ${{ secrets.NPM_TOKEN }}
37+
38+
- name: Create a git tag
39+
run: git tag $NEW_VERSION && git push --tags
40+
env:
41+
NEW_VERSION: ${{ steps.version.outputs.version }}
42+
43+
- name: GitHub release
44+
uses: actions/create-release@v1
45+
id: create_release
46+
with:
47+
draft: false
48+
prerelease: false
49+
release_name: ${{ steps.version.outputs.version }}
50+
tag_name: ${{ steps.version.outputs.version }}
51+
body_path: CHANGELOG.md
52+
env:
53+
GITHUB_TOKEN: ${{ github.token }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gnosis.pm/safe-react-gateway-sdk",
3-
"version": "2.5.0",
3+
"version": "2.5.2",
44
"main": "dist/index.min.js",
55
"types": "dist/index.d.ts",
66
"files": [

0 commit comments

Comments
 (0)