Skip to content

Commit 4c4b4b5

Browse files
authored
feat(publish_node_package): Validate whether published package is available to pull (#224)
1 parent 7137cbe commit 4c4b4b5

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

.github/workflows/publish_node_package.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
working-directory: ${{ inputs.working_directory }}
104104
run: |
105105
npm version prerelease --preid `git rev-parse --short HEAD`-`date +%Y%m%d%H%M` --no-git-tag-version
106+
echo "package_version=$(npm pkg get version | tr -d '\"')" >> $GITHUB_ENV
106107
107108
- name: Configure node
108109
if: |
@@ -113,7 +114,6 @@ jobs:
113114
node-version: ${{ inputs.node_version }}
114115
registry-url: '${{ inputs.npm_registry_url }}'
115116
scope: '@flowfuse'
116-
always-auth: true
117117

118118
- name: Set dependecies versions
119119
if: ${{ inputs.package_dependencies != '' }}
@@ -171,3 +171,22 @@ jobs:
171171
npm publish ${{ env.NPM_PUBLISH_PARAMETERS }} --tag ${{ env.release_name }}
172172
env:
173173
NODE_AUTH_TOKEN: ${{ secrets.npm_registry_token }}
174+
175+
- name: Verify published package is available
176+
if: ${{ inputs.publish_package }}
177+
working-directory: ${{ inputs.working_directory }}
178+
run: |
179+
attempt=0
180+
while true; do
181+
attempt=$((attempt + 1))
182+
published_version=$(npm view "${{ inputs.package_name }}@${{ env.package_version }}" version --prefer-online 2>/dev/null || true)
183+
tagged_version=$(npm view "${{ inputs.package_name }}" "dist-tags.${{ env.release_name }}" --prefer-online 2>/dev/null || true)
184+
if [ "$published_version" = "${{ env.package_version }}" ] && [ "$tagged_version" = "${{ env.package_version }}" ]; then
185+
echo "### :white_check_mark: ${{ inputs.package_name }}@${{ env.package_version }} available, tag \`${{ env.release_name }}\` resolves to it" >> $GITHUB_STEP_SUMMARY
186+
exit 0
187+
fi
188+
echo "Attempt $attempt: version=${published_version:-missing} tag=${tagged_version:-missing} expected=${{ env.package_version }}; retrying in 30s"
189+
sleep 30
190+
done
191+
env:
192+
NODE_AUTH_TOKEN: ${{ secrets.npm_registry_token }}

0 commit comments

Comments
 (0)