From 274bf86ced79dedc883c6d57997b7a462c4b0880 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 14 Nov 2026 08:49:27 -0800 Subject: [PATCH 1/2] ci(release): attach missing ZIP files to published releases Build and upload the distribution and examples archives when a release has no matching attachment. Preserve existing files on repeat runs. Run uploads in a separate job so npm publishing can finish on its own. --- .github/workflows/publish-npm.yml | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 1970199435..f046417470 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -59,3 +59,68 @@ jobs: - name: Stage package on npm for maintainer approval run: npm stage publish --tag "${{ steps.package.outputs.tag }}" + + release-assets: + if: ${{ github.repository == 'twbs/bootstrap' && startsWith(github.event.release.tag_name, 'v') }} + runs-on: ubuntu-latest + permissions: + contents: write + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + steps: + - name: Clone repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.release.tag_name }} + persist-credentials: false + + - name: Set up Node.js + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: '24' + package-manager-cache: false + + - name: Verify release version + run: | + node --input-type=commonjs <<'NODE' + const fs = require('node:fs') + const { name, version } = JSON.parse(fs.readFileSync('package.json', 'utf8')) + if (name !== 'bootstrap' || process.env.RELEASE_TAG !== `v${version}`) { + throw new Error(`Release ${process.env.RELEASE_TAG} does not match ${name}@${version}`) + } + NODE + + - name: Check release assets + id: assets + env: + GH_TOKEN: ${{ github.token }} + run: | + assets=$(gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name') + for suffix in dist examples; do + file="bootstrap-${RELEASE_TAG#v}-${suffix}.zip" + if ! grep -Fxq -- "$file" <<< "$assets"; then + echo "missing=true" >> "$GITHUB_OUTPUT" + break + fi + done + + - name: Install npm dependencies + if: steps.assets.outputs.missing == 'true' + run: npm ci + + - name: Build release archives + if: steps.assets.outputs.missing == 'true' + run: npm run release + + - name: Upload missing release assets + if: steps.assets.outputs.missing == 'true' + env: + GH_TOKEN: ${{ github.token }} + run: | + assets=$(gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name') + for suffix in dist examples; do + file="bootstrap-${RELEASE_TAG#v}-${suffix}.zip" + if ! grep -Fxq -- "$file" <<< "$assets"; then + gh release upload "$RELEASE_TAG" "$file" --repo "$GITHUB_REPOSITORY" + fi + done From 7752162482360c20a84f6543a3651ab59d0ab47d Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 14 Nov 2026 12:34:02 -0800 Subject: [PATCH 2/2] ci(release): require approval before attaching ZIP files Save the built archives as workflow artifacts so maintainers can review them before release uploads. Require the release environment for the upload job and download the saved artifact by its immutable ID. Keep the existing filename checks before building and uploading. --- .github/workflows/publish-npm.yml | 37 +++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index f046417470..3661d5db0e 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -64,7 +64,11 @@ jobs: if: ${{ github.repository == 'twbs/bootstrap' && startsWith(github.event.release.tag_name, 'v') }} runs-on: ubuntu-latest permissions: - contents: write + contents: read + outputs: + missing: ${{ steps.assets.outputs.missing }} + artifact-id: ${{ steps.archives.outputs.artifact-id }} + artifact-url: ${{ steps.archives.outputs.artifact-url }} env: RELEASE_TAG: ${{ github.event.release.tag_name }} steps: @@ -112,8 +116,37 @@ jobs: if: steps.assets.outputs.missing == 'true' run: npm run release - - name: Upload missing release assets + - name: Save release archives for review if: steps.assets.outputs.missing == 'true' + id: archives + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: release-archives-${{ github.run_attempt }} + path: | + bootstrap-*-dist.zip + bootstrap-*-examples.zip + if-no-files-found: error + compression-level: 0 + + upload-release-assets: + needs: release-assets + if: needs.release-assets.outputs.missing == 'true' + runs-on: ubuntu-latest + environment: + name: release + url: ${{ needs.release-assets.outputs.artifact-url }} + permissions: + contents: write + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + steps: + - name: Download approved release archives + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + artifact-ids: ${{ needs.release-assets.outputs.artifact-id }} + merge-multiple: true + + - name: Upload missing release assets env: GH_TOKEN: ${{ github.token }} run: |