Skip to content

Commit 2765567

Browse files
committed
refactor: change pact-transformer publish trigger to version-based check
- Remove tag-based trigger for publishing - Add version check against npm registry before publishing - Only publish on main branch push if version is different - Keep all build and test steps as before
1 parent 0bff04d commit 2765567

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

.github/workflows/pact-transformer-ci.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ on:
1818
push:
1919
branches:
2020
- main
21-
tags:
22-
- "@pact-toolbox/pact-transformer@*"
2321
paths-ignore:
2422
- "**/*.md"
2523
- "LICENSE"
@@ -429,7 +427,7 @@ jobs:
429427
- test-linux-x64-musl-binding
430428
- test-linux-aarch64-gnu-binding
431429
- test-linux-aarch64-musl-binding
432-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/@pact-toolbox/pact-transformer@')
430+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
433431
steps:
434432
- uses: actions/checkout@v4
435433
- name: Setup node
@@ -438,18 +436,39 @@ jobs:
438436
node-version: 22
439437
- uses: pnpm/action-setup@v4
440438

439+
- name: Check if version needs publishing
440+
id: version_check
441+
run: |
442+
cd crates/pact-transformer
443+
LOCAL_VERSION=$(node -p "require('./package.json').version")
444+
echo "Local version: $LOCAL_VERSION"
445+
446+
# Check if package exists on npm
447+
if npm view @pact-toolbox/pact-transformer@$LOCAL_VERSION version 2>/dev/null; then
448+
echo "Version $LOCAL_VERSION already published"
449+
echo "should_publish=false" >> $GITHUB_OUTPUT
450+
else
451+
echo "Version $LOCAL_VERSION not published yet"
452+
echo "should_publish=true" >> $GITHUB_OUTPUT
453+
fi
454+
441455
- name: Install dependencies
456+
if: steps.version_check.outputs.should_publish == 'true'
442457
run: pnpm install --frozen-lockfile
443458
- name: Download all artifacts
459+
if: steps.version_check.outputs.should_publish == 'true'
444460
uses: actions/download-artifact@v4
445461
with:
446462
path: crates/pact-transformer/artifacts
447463
- name: Move artifacts
464+
if: steps.version_check.outputs.should_publish == 'true'
448465
run: cd crates/pact-transformer && pnpm artifacts
449466
- name: List packages
467+
if: steps.version_check.outputs.should_publish == 'true'
450468
run: ls -R ./crates/pact-transformer/npm
451469
shell: bash
452470
- name: Publish
471+
if: steps.version_check.outputs.should_publish == 'true'
453472
run: |
454473
npm config set provenance true
455474
cd crates/pact-transformer

0 commit comments

Comments
 (0)