Skip to content

Commit 401beb2

Browse files
authored
Add manual trigger to web publish (#140)
### What changes are you making? <!-- Please describe why you are making these changes --> ### How to test <!-- Please outline the steps to test your changes --> --- ### Before you merge > [!IMPORTANT] > > - [ ] I've added tests to support my implementation > - [ ] I have read and agree with the [Contribution Guidelines](./CONTRIBUTING.md) > - [ ] I have read and agree with the [Code of Conduct](./CODE_OF_CONDUCT.md) > - [ ] I've updated the relevant platform README (`platforms/swift/README.md` and/or `platforms/android/README.md`) --- <details> <summary>Releasing a new Swift version?</summary> - [ ] I have bumped the version in `ShopifyCheckoutKit.podspec` - [ ] I have bumped the version in `platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift` - [ ] I have updated `platforms/swift/CHANGELOG.md` - [ ] I have updated the SwiftPM/CocoaPods version snippets in `platforms/swift/README.md` (major version only) </details> <details> <summary>Releasing a new Android version?</summary> - [ ] I have bumped the `versionName` in `platforms/android/lib/build.gradle` - [ ] I have updated `platforms/android/CHANGELOG.md` - [ ] I have updated the Gradle/Maven version snippets in `platforms/android/README.md` </details> > [!TIP] > See the [Contributing documentation](./CONTRIBUTING.md) for the full release process per platform.
1 parent 1212038 commit 401beb2

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

.github/workflows/web-publish.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ on:
1010
required: false
1111
type: string
1212
dry-run:
13-
description: "Run the full pipeline + pack but skip the actual publish."
13+
description: "Run the full pipeline + pack but skip the actual publish. Defaults to true for manual safety; uncheck to actually publish."
1414
required: false
1515
type: boolean
16-
default: false
16+
default: true
1717

1818
permissions:
1919
contents: read
@@ -26,11 +26,16 @@ concurrency:
2626
jobs:
2727
publish:
2828
name: Publish @shopify/checkout-kit to npm
29-
# Only run for web releases. Web tags are `web/X.Y.Z` to disambiguate from
30-
# Swift's bare semver and Android's `android/X.Y.Z`.
29+
# Only run when either:
30+
# - A GitHub Release tagged `web/X.Y.Z` is published (auto trigger), OR
31+
# - The workflow is manually dispatched from the `main` branch. The
32+
# branch lock prevents fat-fingering a publish from a feature branch
33+
# that hasn't been reviewed.
34+
# Web tags are `web/X.Y.Z` to disambiguate from Swift's bare semver and
35+
# Android's `android/X.Y.Z`.
3136
if: |
32-
github.event_name == 'workflow_dispatch'
33-
|| startsWith(github.event.release.tag_name, 'web/')
37+
(github.event_name == 'release' && startsWith(github.event.release.tag_name, 'web/'))
38+
|| (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main')
3439
environment:
3540
name: npm-web
3641
url: https://www.npmjs.com/package/@shopify/checkout-kit
@@ -70,6 +75,18 @@ jobs:
7075
fi
7176
echo "✓ Tag '$TAG_NAME' matches package.json version '$VERSION_FROM_PKG'."
7277
78+
- name: Verify version is not already published
79+
run: |
80+
set -euo pipefail
81+
NAME=$(node -p "require('./package.json').name")
82+
VERSION=$(node -p "require('./package.json').version")
83+
URL="https://registry.npmjs.org/${NAME}/${VERSION}"
84+
if curl -fs "$URL" > /dev/null; then
85+
echo "::error::${NAME}@${VERSION} is already published on npm. Bump platforms/web/package.json before re-running."
86+
exit 1
87+
fi
88+
echo "::notice::${NAME}@${VERSION} is not yet on npm — safe to proceed."
89+
7390
- name: Lint (typecheck + oxlint + format)
7491
run: pnpm lint
7592

0 commit comments

Comments
 (0)