Promote to npm latest #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Promote to npm latest | |
| # Manually point the npm "latest" dist-tag (what `npm install <pkg>` resolves to) | |
| # at a chosen version. Pick a source dist-tag from the dropdown — the version it | |
| # currently points to is promoted — or type an exact version to override. | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| source: | |
| description: 'Promote the version currently on this dist-tag (alphas are intentionally excluded)' | |
| required: true | |
| default: rc | |
| type: choice | |
| options: | |
| - rc | |
| - beta | |
| version: | |
| description: 'Exact version override (optional, e.g. 1.0.0-rc.1)' | |
| required: false | |
| type: string | |
| jobs: | |
| promote: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Resolve version to promote | |
| id: resolve | |
| run: | | |
| PKG=strapi-plugin-form-builder-cms | |
| VERSION="${{ inputs.version }}" | |
| if [ -z "$VERSION" ]; then | |
| VERSION=$(npm view "$PKG@${{ inputs.source }}" version 2>/dev/null) | |
| fi | |
| if [ -z "$VERSION" ]; then | |
| echo "❌ Could not resolve a version (tag '${{ inputs.source }}' may be unset and no override given)." | |
| exit 1 | |
| fi | |
| if ! npm view "$PKG@$VERSION" version >/dev/null 2>&1; then | |
| echo "❌ $VERSION is not published on npm." | |
| exit 1 | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Promoting $VERSION to latest." | |
| - name: Point latest at ${{ steps.resolve.outputs.version }} | |
| run: npm dist-tag add strapi-plugin-form-builder-cms@${{ steps.resolve.outputs.version }} latest | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Done | |
| run: echo "✅ npm 'latest' now points to ${{ steps.resolve.outputs.version }}" |