From 5dd5bac54af9f45761ec1bb2e47f175110f7bde4 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Fri, 3 Oct 2025 08:37:40 -0700 Subject: [PATCH] Remove dist folder from repo - Update existing Actions to compile CSS and JS - Add new Actions for dedicated compilation - Update publish and release scripts to build and commit dist --- .github/workflows/build-css.yml | 46 +++++++++++++++ .github/workflows/build-js.yml | 46 +++++++++++++++ .github/workflows/bundlewatch.yml | 57 ++++++++++++++++++- .github/workflows/cdn.yml | 51 +++++++++++++++++ .github/workflows/css.yml | 37 +++++++++++- .github/workflows/docs.yml | 56 ++++++++++++++++++ .github/workflows/js.yml | 39 ++++++++++++- .github/workflows/publish-nuget.yml | 17 ++++++ .github/workflows/release.yml | 88 +++++++++++++++++++++++++++++ .gitignore | 1 + 10 files changed, 433 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build-css.yml create mode 100644 .github/workflows/build-js.yml create mode 100644 .github/workflows/cdn.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build-css.yml b/.github/workflows/build-css.yml new file mode 100644 index 0000000000..23304db083 --- /dev/null +++ b/.github/workflows/build-css.yml @@ -0,0 +1,46 @@ +name: Build CSS + +on: + pull_request: + paths: + - 'scss/**' + - 'build/**' + - 'package.json' + - 'package-lock.json' + workflow_dispatch: + +env: + FORCE_COLOR: 2 + NODE: 22 + +permissions: + contents: read + +jobs: + build-css: + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Set up Node.js + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: "${{ env.NODE }}" + cache: npm + + - name: Install npm dependencies + run: npm ci + + - name: Build CSS + run: npm run css + + - name: Upload CSS artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: css-dist + path: dist/css/ + retention-days: 1 diff --git a/.github/workflows/build-js.yml b/.github/workflows/build-js.yml new file mode 100644 index 0000000000..fd3fc8f13f --- /dev/null +++ b/.github/workflows/build-js.yml @@ -0,0 +1,46 @@ +name: Build JS + +on: + pull_request: + paths: + - 'js/**' + - 'build/**' + - 'package.json' + - 'package-lock.json' + workflow_dispatch: + +env: + FORCE_COLOR: 2 + NODE: 22 + +permissions: + contents: read + +jobs: + build-js: + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Set up Node.js + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: "${{ env.NODE }}" + cache: npm + + - name: Install npm dependencies + run: npm ci + + - name: Build JS + run: npm run js + + - name: Upload JS artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: js-dist + path: dist/js/ + retention-days: 1 diff --git a/.github/workflows/bundlewatch.yml b/.github/workflows/bundlewatch.yml index 9a1d81679e..3e4388a14b 100644 --- a/.github/workflows/bundlewatch.yml +++ b/.github/workflows/bundlewatch.yml @@ -15,7 +15,51 @@ permissions: contents: read jobs: + build-dist: + runs-on: ubuntu-latest + outputs: + css-artifact: ${{ steps.css-artifact.outputs }} + js-artifact: ${{ steps.js-artifact.outputs }} + + steps: + - name: Clone repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Set up Node.js + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: "${{ env.NODE }}" + cache: npm + + - name: Install npm dependencies + run: npm ci + + - name: Build CSS + run: npm run css + + - name: Build JS + run: npm run js + + - name: Upload CSS artifacts + id: css-artifact + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: css-dist + path: dist/css/ + retention-days: 1 + + - name: Upload JS artifacts + id: js-artifact + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: js-dist + path: dist/js/ + retention-days: 1 + bundlewatch: + needs: build-dist runs-on: ubuntu-latest steps: @@ -33,8 +77,17 @@ jobs: - name: Install npm dependencies run: npm ci - - name: Run dist - run: npm run dist + - name: Download CSS artifacts + uses: actions/download-artifact@v4 + with: + name: css-dist + path: dist/css/ + + - name: Download JS artifacts + uses: actions/download-artifact@v4 + with: + name: js-dist + path: dist/js/ - name: Run bundlewatch run: npm run bundlewatch diff --git a/.github/workflows/cdn.yml b/.github/workflows/cdn.yml new file mode 100644 index 0000000000..06941a71b4 --- /dev/null +++ b/.github/workflows/cdn.yml @@ -0,0 +1,51 @@ +name: CDN Distribution + +on: + release: + types: [published] + workflow_dispatch: + +env: + FORCE_COLOR: 2 + NODE: 22 + +permissions: + contents: read + +jobs: + build-cdn: + runs-on: ubuntu-latest + if: ${{ github.repository == 'twbs/bootstrap' && startsWith(github.event.release.tag_name, 'v') }} + + steps: + - name: Clone repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Set up Node.js + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: "${{ env.NODE }}" + cache: npm + + - name: Install npm dependencies + run: npm ci + + - name: Build CSS + run: npm run css + + - name: Build JS + run: npm run js + + - name: Generate SRI hashes + run: npm run release-sri + + - name: Upload to CDN + # This would typically upload to a CDN service like jsDelivr, unpkg, etc. + # The actual implementation would depend on the CDN service used + run: | + echo "CDN upload would happen here" + echo "Files ready for CDN distribution:" + ls -la dist/css/ + ls -la dist/js/ diff --git a/.github/workflows/css.yml b/.github/workflows/css.yml index 8fd608c430..7ae79a6a5d 100644 --- a/.github/workflows/css.yml +++ b/.github/workflows/css.yml @@ -15,8 +15,10 @@ permissions: contents: read jobs: - css: + build-css: runs-on: ubuntu-latest + outputs: + css-artifact: ${{ steps.css-artifact.outputs }} steps: - name: Clone repository @@ -36,5 +38,38 @@ jobs: - name: Build CSS run: npm run css + - name: Upload CSS artifacts + id: css-artifact + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: css-dist + path: dist/css/ + retention-days: 1 + + css: + needs: build-css + runs-on: ubuntu-latest + + steps: + - name: Clone repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Set up Node.js + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: "${{ env.NODE }}" + cache: npm + + - name: Install npm dependencies + run: npm ci + + - name: Download CSS artifacts + uses: actions/download-artifact@v4 + with: + name: css-dist + path: dist/css/ + - name: Run CSS tests run: npm run css-test diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 93035f41de..5e9ce577ee 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -15,7 +15,51 @@ permissions: contents: read jobs: + build-dist: + runs-on: ubuntu-latest + outputs: + css-artifact: ${{ steps.css-artifact.outputs }} + js-artifact: ${{ steps.js-artifact.outputs }} + + steps: + - name: Clone repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Set up Node.js + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: "${{ env.NODE }}" + cache: npm + + - name: Install npm dependencies + run: npm ci + + - name: Build CSS + run: npm run css + + - name: Build JS + run: npm run js + + - name: Upload CSS artifacts + id: css-artifact + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: css-dist + path: dist/css/ + retention-days: 1 + + - name: Upload JS artifacts + id: js-artifact + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: js-dist + path: dist/js/ + retention-days: 1 + docs: + needs: build-dist runs-on: ubuntu-latest steps: @@ -33,6 +77,18 @@ jobs: - name: Install npm dependencies run: npm ci + - name: Download CSS artifacts + uses: actions/download-artifact@v4 + with: + name: css-dist + path: dist/css/ + + - name: Download JS artifacts + uses: actions/download-artifact@v4 + with: + name: js-dist + path: dist/js/ + - name: Build docs run: npm run docs-build diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index 5606ecf7fd..59b922f0eb 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -15,7 +15,39 @@ permissions: contents: read jobs: + build-js: + runs-on: ubuntu-latest + outputs: + js-artifact: ${{ steps.js-artifact.outputs }} + + steps: + - name: Clone repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Set up Node.js + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: ${{ env.NODE }} + cache: npm + + - name: Install npm dependencies + run: npm ci + + - name: Build JS + run: npm run js + + - name: Upload JS artifacts + id: js-artifact + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: js-dist + path: dist/js/ + retention-days: 1 + run: + needs: build-js permissions: # allow coverallsapp/github-action to create new checks issues and fetch code checks: write @@ -38,8 +70,11 @@ jobs: - name: Install npm dependencies run: npm ci - - name: Run dist - run: npm run js + - name: Download JS artifacts + uses: actions/download-artifact@v4 + with: + name: js-dist + path: dist/js/ - name: Run JS tests run: npm run js-test diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index b78023b92a..ad5c554e59 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -13,11 +13,28 @@ jobs: if: ${{ github.repository == 'twbs/bootstrap' && startsWith(github.event.release.tag_name, 'v') }} env: GITHUB_REF_NAME: ${{ github.ref_name }} + FORCE_COLOR: 2 + NODE: 22 steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false + - name: Set up Node.js + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: "${{ env.NODE }}" + cache: npm + + - name: Install npm dependencies + run: npm ci + + - name: Build CSS + run: npm run css + + - name: Build JS + run: npm run js + - name: Set up NuGet uses: nuget/setup-nuget@323ab0502cd38fdc493335025a96c8fdb0edc71f # v2.0.1 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..07b9655f71 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,88 @@ +name: Release + +on: + release: + types: [published] + workflow_dispatch: + +env: + FORCE_COLOR: 2 + NODE: 22 + +permissions: + contents: write + +jobs: + build-and-release: + runs-on: ubuntu-latest + if: ${{ github.repository == 'twbs/bootstrap' && (github.event_name == 'release' || github.event_name == 'workflow_dispatch') }} + + steps: + - name: Clone repository + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + + - name: Set up Node.js + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: "${{ env.NODE }}" + cache: npm + + - name: Install npm dependencies + run: npm ci + + - name: Build CSS + run: npm run css + + - name: Build JS + run: npm run js + + - name: Generate SRI hashes + run: npm run release-sri + + - name: Build docs + run: npm run docs-build + + - name: Create release zip + run: npm run release-zip + + - name: Create examples zip + run: npm run release-zip-examples + + - name: Upload dist files to release + uses: actions/upload-release-asset@v1 + if: ${{ github.event_name == 'release' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./bootstrap-${{ github.event.release.tag_name }}-dist.zip + asset_name: bootstrap-${{ github.event.release.tag_name }}-dist.zip + asset_content_type: application/zip + + - name: Upload examples to release + uses: actions/upload-release-asset@v1 + if: ${{ github.event_name == 'release' }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./bootstrap-${{ github.event.release.tag_name }}-examples.zip + asset_name: bootstrap-${{ github.event.release.tag_name }}-examples.zip + asset_content_type: application/zip + + - name: Commit dist files for npm + if: ${{ github.event_name == 'release' }} + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add dist/ + git commit -m "Add dist files for release ${{ github.event.release.tag_name }}" || exit 0 + git push + + - name: Publish to npm + if: ${{ github.event_name == 'release' }} + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index 235ad54948..6d2c89f966 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ Thumbs.db *.komodoproject # Folders to ignore +/dist/ /dist-sass/ /js/coverage/ /node_modules/ -- 2.47.3