|
81 | 81 | fi |
82 | 82 | npm whoami --registry=https://registry.npmjs.org/ |
83 | 83 |
|
| 84 | + - name: Inspect existing registry state |
| 85 | + id: registry-state |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + VERSION=$(node -p "require('./package.json').version") |
| 89 | + EXPECTED_GIT_HEAD=$(git rev-parse HEAD) |
| 90 | + PUBLISHED_VERSION=$(npm view "monsqlize@${VERSION}" version --registry=https://registry.npmjs.org/ 2>/dev/null || true) |
| 91 | + if [ "${PUBLISHED_VERSION}" != "${VERSION}" ]; then |
| 92 | + echo "already_published=false" >> "${GITHUB_OUTPUT}" |
| 93 | + exit 0 |
| 94 | + fi |
| 95 | +
|
| 96 | + REGISTRY_GIT_HEAD=$(npm view "monsqlize@${VERSION}" gitHead --registry=https://registry.npmjs.org/) |
| 97 | + if [ "${REGISTRY_GIT_HEAD}" != "${EXPECTED_GIT_HEAD}" ]; then |
| 98 | + echo "::error::monsqlize@${VERSION} already exists with gitHead=${REGISTRY_GIT_HEAD:-missing}; expected=${EXPECTED_GIT_HEAD}" |
| 99 | + exit 1 |
| 100 | + fi |
| 101 | + echo "monsqlize@${VERSION} already exists from this exact tag commit; publish will be skipped and registry acceptance will resume." |
| 102 | + echo "already_published=true" >> "${GITHUB_OUTPUT}" |
| 103 | +
|
84 | 104 | - name: Publish to npm |
| 105 | + if: steps.registry-state.outputs.already_published != 'true' |
85 | 106 | run: npm publish --provenance --access public --ignore-scripts |
86 | 107 | env: |
87 | 108 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
@@ -113,7 +134,7 @@ jobs: |
113 | 134 | mkdir -p "${CONSUMER_DIR}" |
114 | 135 | cd "${CONSUMER_DIR}" |
115 | 136 | npm init -y |
116 | | - npm install "monsqlize@${VERSION}" "[email protected]" --ignore-scripts --no-audit --no-fund --registry=https://registry.npmjs.org/ |
| 137 | + npm install "monsqlize@${VERSION}" "[email protected]" "@types/[email protected]" --ignore-scripts --no-audit --no-fund --registry=https://registry.npmjs.org/ |
117 | 138 | node -e "const p=require('monsqlize/package.json'); const M=require('monsqlize'); if(!M || p.version!==process.argv[1] || typeof M.dataTasks?.preview!=='function') process.exit(1)" "${VERSION}" |
118 | 139 | node --input-type=module -e "import M,{dataTasks} from 'monsqlize'; if(!M || typeof dataTasks?.apply!=='function') process.exit(1)" |
119 | 140 | node -e "require('node:fs').writeFileSync('consumer.ts', \"import MonSQLize, { dataTasks } from 'monsqlize';\\nvoid MonSQLize; void dataTasks.preview;\\n\")" |
|
0 commit comments