fix(telemetry-core): 🐛 fix incorrect reference to ESM #22
Workflow file for this run
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: Publish NPM Package | |
| on: | |
| push: | |
| tags: | |
| - 'heft-*-plugin@v*.*.*' | |
| - 'telemetry-core@v*.*.*' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| validate: | |
| name: Validate Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Install Rush | |
| run: npm install -g @microsoft/rush@5.162.0 | |
| - name: Install dependencies | |
| run: rush update | |
| - name: Build packages | |
| run: rush rebuild --verbose | |
| - name: Run tests | |
| run: rush test | |
| publish: | |
| name: Publish to NPM | |
| needs: validate | |
| runs-on: ubuntu-latest | |
| # environment: production # Temporarily disabled for testing | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| registry-url: 'https://registry.npmjs.org' | |
| # npm v11.5.1+ required for trusted publishing | |
| - name: Update npm (v11.5.1+) | |
| run: npm install -g npm@latest | |
| - name: Install Rush | |
| run: npm install -g @microsoft/rush@5.162.0 | |
| - name: Install dependencies | |
| run: rush update | |
| - name: Build packages | |
| run: rush rebuild --verbose | |
| - name: Extract package name, version, and determine dist-tag | |
| id: version | |
| run: | | |
| # Extract from tag format: heft-stylelint-plugin@v0.1.0 or telemetry-core@v0.1.0 | |
| FULL_TAG=${GITHUB_REF#refs/tags/} | |
| PACKAGE_SHORT_NAME=${FULL_TAG%@v*} | |
| VERSION=${FULL_TAG#*@v} | |
| echo "package_short_name=$PACKAGE_SHORT_NAME" >> $GITHUB_OUTPUT | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # Map package short name to folder path | |
| # Plugins live in heft-plugins/, libraries live in packages/ | |
| case $PACKAGE_SHORT_NAME in | |
| heft-*-plugin) | |
| PACKAGE_PATH="heft-plugins/${PACKAGE_SHORT_NAME}" | |
| ;; | |
| telemetry-core) | |
| PACKAGE_PATH="packages/${PACKAGE_SHORT_NAME}" | |
| ;; | |
| *) | |
| echo "Error: Unknown package '${PACKAGE_SHORT_NAME}'" | |
| exit 1 | |
| ;; | |
| esac | |
| echo "package_path=$PACKAGE_PATH" >> $GITHUB_OUTPUT | |
| echo "Publishing package from directory: $PACKAGE_PATH" | |
| echo "Version: $VERSION" | |
| # Determine NPM dist-tag based on version format | |
| if [[ $VERSION =~ -beta\. ]]; then | |
| echo "dist_tag=next" >> $GITHUB_OUTPUT | |
| echo "prerelease=true" >> $GITHUB_OUTPUT | |
| elif [[ $VERSION =~ -rc\. ]]; then | |
| echo "dist_tag=next" >> $GITHUB_OUTPUT | |
| echo "prerelease=true" >> $GITHUB_OUTPUT | |
| elif [[ $VERSION =~ -alpha\. ]]; then | |
| echo "dist_tag=next" >> $GITHUB_OUTPUT | |
| echo "prerelease=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "dist_tag=latest" >> $GITHUB_OUTPUT | |
| echo "prerelease=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Get package full name from package.json | |
| id: package | |
| run: | | |
| cd ${{ steps.version.outputs.package_path }} | |
| PACKAGE_NAME=$(node -p "require('./package.json').name") | |
| echo "name=$PACKAGE_NAME" >> $GITHUB_OUTPUT | |
| echo "Full package name: $PACKAGE_NAME" | |
| - name: Inject AppInsights connection string into @voitanos/heft-plugins-telemetry-core | |
| run: node packages/telemetry-core/scripts/inject-connection-string.js | |
| env: | |
| HEFT_PLUGINS_APP_INSIGHTS_CONNECTION_STRING: ${{ vars.HEFT_PLUGINS_APP_INSIGHTS_CONNECTION_STRING }} | |
| - name: Configure npm for OIDC authentication | |
| run: | | |
| npm config delete //registry.npmjs.org/:_authToken 2>/dev/null || true | |
| npm config delete always-auth 2>/dev/null || true | |
| npm config delete //registry.npmjs.org/:always-auth 2>/dev/null || true | |
| - name: Publish specific package to NPM with provenance | |
| run: | | |
| cd ${{ steps.version.outputs.package_path }} | |
| npm publish --access public --tag ${{ steps.version.outputs.dist_tag }} --provenance | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: ${{ steps.package.outputs.name }}@${{ steps.version.outputs.version }} | |
| generate_release_notes: true | |
| prerelease: ${{ steps.version.outputs.prerelease }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |