Skip to content

Commit fd7ebc5

Browse files
committed
feat: added auto deployment for npm
1 parent 0fad1ab commit fd7ebc5

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Use Node.js
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: "18.x"
18+
registry-url: "https://registry.npmjs.org"
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Verify package version matches release tag
24+
run: |
25+
PACKAGE_VERSION="v$(node -p "require('./package.json').version")"
26+
RELEASE_TAG="${{ github.ref_name }}"
27+
if [ "$PACKAGE_VERSION" != "$RELEASE_TAG" ]; then
28+
echo "❌ package.json version ($PACKAGE_VERSION) does not match release tag ($RELEASE_TAG)"
29+
exit 1
30+
fi
31+
echo "✅ Version match confirmed: $RELEASE_TAG"
32+
33+
- name: Publish to npm
34+
run: npm publish --access public
35+
env:
36+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

‎package.json‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44
"description": "CLI tool to sync a local git working directory with a remote FTP/SFTP server.",
55
"main": "src/index.js",
66
"bin": {
7-
"local-git-deploy": "./bin/cli.js"
7+
"local-git-deploy": "bin/cli.js"
88
},
99
"scripts": {
1010
"test": "echo \"Error: no test specified\" && exit 1"
1111
},
12-
"keywords": ["ftp", "sftp", "ftps", "deploy", "git"],
12+
"keywords": [
13+
"ftp",
14+
"sftp",
15+
"ftps",
16+
"deploy",
17+
"git"
18+
],
1319
"author": "pablo-codes",
1420
"license": "ISC",
1521
"engines": {

0 commit comments

Comments
 (0)