Skip to content

Commit 5e5a6c9

Browse files
committed
ci: npm release
1 parent 743bf83 commit 5e5a6c9

File tree

7 files changed

+32
-55
lines changed

7 files changed

+32
-55
lines changed

.github/workflows/nodejs-pgsql14.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ jobs:
4949
npm run build
5050
- name: Test
5151
run: npm test
52-
env:
53-
POSTGRES_PORT: 5432
5452
- uses: phoenix-actions/test-reporting@v8
5553
if: success() || failure()
5654
id: test-report

.github/workflows/nodejs-pgsql15.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ jobs:
4949
npm run build
5050
- name: Test
5151
run: npm test
52-
env:
53-
POSTGRES_PORT: 5432
5452
- uses: phoenix-actions/test-reporting@v8
5553
if: success() || failure()
5654
id: test-report

.github/workflows/nodejs-pgsql16.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ jobs:
4949
npm run build
5050
- name: Test
5151
run: npm test
52-
env:
53-
POSTGRES_PORT: 5432
5452
- uses: phoenix-actions/test-reporting@v8
5553
if: success() || failure()
5654
id: test-report

.github/workflows/nodejs-pgsql17.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ jobs:
4949
npm run build
5050
- name: Test
5151
run: npm test
52-
env:
53-
POSTGRES_PORT: 5432
5452
- uses: phoenix-actions/test-reporting@v8
5553
if: success() || failure()
5654
id: test-report

.github/workflows/npm-publish.yml

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
1-
name: Manual NPM Release
1+
name: NPM Release on PR Merge
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
version_type:
7-
description: 'Version bump type'
8-
required: true
9-
default: 'patch'
10-
type: choice
11-
options:
12-
- patch
13-
- minor
14-
- major
15-
dry_run:
16-
description: 'Dry run (test without publishing)'
17-
required: false
18-
default: false
19-
type: boolean
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
207

218
jobs:
229
release:
10+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')
2311
runs-on: ubuntu-latest
12+
environment: github action
2413

2514
services:
2615
postgres:
@@ -35,8 +24,6 @@ jobs:
3524
steps:
3625
- name: Checkout code
3726
uses: actions/checkout@v4
38-
with:
39-
token: ${{ secrets.GITHUB_TOKEN }}
4027

4128
- name: Setup Node.js
4229
uses: actions/setup-node@v4
@@ -47,40 +34,38 @@ jobs:
4734
- name: Install dependencies
4835
run: npm ci
4936

50-
- name: Configure git
37+
- name: Get package version
38+
id: package_version
5139
run: |
52-
git config --local user.email "action@github.com"
53-
git config --local user.name "GitHub Action"
54-
55-
- name: Bump version and create tag
56-
id: version_bump
57-
run: |
58-
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
59-
echo "🧪 DRY RUN MODE"
60-
NEW_VERSION=$(npm version ${{ github.event.inputs.version_type }} --no-git-tag-version)
61-
echo "Would bump to version: $NEW_VERSION"
62-
git checkout -- package.json package-lock.json
63-
else
64-
NEW_VERSION=$(npm version ${{ github.event.inputs.version_type }})
65-
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
66-
git push origin main --follow-tags
67-
fi
40+
VERSION=$(node -p "require('./package.json').version")
41+
echo "version=$VERSION" >> $GITHUB_OUTPUT
6842
6943
- name: Run tests
70-
env:
71-
POSTGRES_PORT: 5432
7244
run: npm test
7345

7446
- name: Build
7547
run: npm run build
7648

7749
- name: Publish to NPM
50+
run: npm publish
51+
env:
52+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
53+
54+
- name: Create tag
7855
run: |
79-
if [ "${{ github.event.inputs.dry_run }}" = "true" ]; then
80-
echo "🧪 DRY RUN: Would publish to NPM"
81-
npm publish --access public --dry-run
82-
else
83-
npm publish --access public
84-
fi
56+
git config --local user.email "action@github.com"
57+
git config --local user.name "GitHub Action"
58+
git tag "v${{ steps.package_version.outputs.version }}"
59+
git push origin "v${{ steps.package_version.outputs.version }}"
8560
env:
86-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
63+
- name: Create GitHub Release
64+
uses: actions/create-release@v1
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
with:
68+
tag_name: "v${{ steps.package_version.outputs.version }}"
69+
release_name: Release "v${{ steps.package_version.outputs.version }}"
70+
draft: false
71+
prerelease: false

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pg-logical-replication",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "PostgreSQL Location Replication client - logical WAL replication streaming",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/test/client-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ClientConfig } from 'pg';
33
// infra/docker-pg-logical-replication/docker-compose.yml
44
export const TestClientConfig: ClientConfig = {
55
host: process.env.POSTGRES_HOST || 'localhost',
6-
port: Number(process.env.POSTGRES_PORT || 54320),
6+
port: Number(process.env.POSTGRES_PORT || 5432),
77
user: 'postgres',
88
password: 'postgrespw',
99
database: 'playground',

0 commit comments

Comments
 (0)