|
1 | 1 | name: Publish |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: [main] |
6 | | - paths: |
7 | | - - "**/package.json" |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - '**/package.json' |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - build: |
11 | | - runs-on: ubuntu-latest |
12 | | - permissions: |
13 | | - contents: read |
14 | | - steps: |
15 | | - - uses: actions/checkout@v6 |
16 | | - - uses: actions/setup-node@v6 |
17 | | - with: |
18 | | - node-version: 24 |
19 | | - - run: npm ci --ignore-scripts |
20 | | - - run: npm run build |
21 | | - - uses: actions/upload-artifact@v7 |
22 | | - with: |
23 | | - name: build-output |
24 | | - path: packages/*/dist/ |
25 | | - retention-days: 1 |
26 | | - if-no-files-found: error |
| 10 | + build: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: read |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v6 |
| 16 | + - uses: actions/setup-node@v6 |
| 17 | + with: |
| 18 | + node-version: 24 |
| 19 | + - run: npm ci --ignore-scripts |
| 20 | + - run: npm run build |
| 21 | + - uses: actions/upload-artifact@v7 |
| 22 | + with: |
| 23 | + name: build-output |
| 24 | + path: packages/*/dist/ |
| 25 | + retention-days: 1 |
| 26 | + if-no-files-found: error |
27 | 27 |
|
28 | | - publish: |
29 | | - needs: build |
30 | | - runs-on: ubuntu-latest |
31 | | - permissions: |
32 | | - contents: write |
33 | | - id-token: write |
34 | | - steps: |
35 | | - - uses: actions/checkout@v6 |
36 | | - - uses: actions/setup-node@v6 |
37 | | - with: |
38 | | - node-version: 24 |
39 | | - registry-url: "https://registry.npmjs.org" |
40 | | - scope: "@script-development" |
41 | | - - uses: actions/download-artifact@v8 |
42 | | - with: |
43 | | - name: build-output |
44 | | - path: packages |
45 | | - - run: npm ci --ignore-scripts |
46 | | - - name: Validate dist artifacts |
47 | | - shell: bash |
48 | | - run: | |
49 | | - set -euo pipefail |
50 | | - REQUIRED=("dist/index.mjs" "dist/index.cjs" "dist/index.d.mts" "dist/index.d.cts") |
51 | | - FAILED=0 |
52 | | - for pkg_dir in packages/*/; do |
53 | | - pkg_name=$(node -p "require('./${pkg_dir}package.json').name") |
54 | | - pack_json=$(cd "$pkg_dir" && npm pack --dry-run --json 2>/dev/null) |
55 | | - for required in "${REQUIRED[@]}"; do |
56 | | - size=$(node -e " |
57 | | - const files = JSON.parse(process.argv[1])[0].files; |
58 | | - const f = files.find(e => e.path === process.argv[2]); |
59 | | - if (!f) { console.log('MISSING'); process.exit(0); } |
60 | | - console.log(f.size); |
61 | | - " "$pack_json" "$required") |
62 | | - if [ "$size" = "MISSING" ]; then |
63 | | - echo "::error::${pkg_name} is missing ${required} in published tarball" |
64 | | - FAILED=1 |
65 | | - elif [ "$size" = "0" ]; then |
66 | | - echo "::error::${pkg_name} ${required} is 0 bytes" |
67 | | - FAILED=1 |
68 | | - fi |
69 | | - done |
70 | | - done |
71 | | - if [ "$FAILED" = "1" ]; then |
72 | | - echo "Pre-publish dist validation failed. Refusing to publish empty or incomplete tarballs." |
73 | | - exit 1 |
74 | | - fi |
75 | | - echo "All packages validated: required dist/ artifacts present and non-empty." |
76 | | - - run: npx changeset publish |
77 | | - env: |
78 | | - NPM_CONFIG_PROVENANCE: "true" |
79 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + publish: |
| 29 | + needs: build |
| 30 | + runs-on: ubuntu-latest |
| 31 | + permissions: |
| 32 | + contents: write |
| 33 | + id-token: write |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v6 |
| 36 | + - uses: actions/setup-node@v6 |
| 37 | + with: |
| 38 | + node-version: 24 |
| 39 | + registry-url: 'https://registry.npmjs.org' |
| 40 | + scope: '@script-development' |
| 41 | + - uses: actions/download-artifact@v8 |
| 42 | + with: |
| 43 | + name: build-output |
| 44 | + path: packages |
| 45 | + - run: npm ci --ignore-scripts |
| 46 | + - name: Validate dist artifacts |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + set -euo pipefail |
| 50 | + REQUIRED=("dist/index.mjs" "dist/index.cjs" "dist/index.d.mts" "dist/index.d.cts") |
| 51 | + FAILED=0 |
| 52 | + for pkg_dir in packages/*/; do |
| 53 | + pkg_name=$(node -p "require('./${pkg_dir}package.json').name") |
| 54 | + pack_json=$(cd "$pkg_dir" && npm pack --dry-run --json 2>/dev/null) |
| 55 | + for required in "${REQUIRED[@]}"; do |
| 56 | + size=$(node -e " |
| 57 | + const files = JSON.parse(process.argv[1])[0].files; |
| 58 | + const f = files.find(e => e.path === process.argv[2]); |
| 59 | + if (!f) { console.log('MISSING'); process.exit(0); } |
| 60 | + console.log(f.size); |
| 61 | + " "$pack_json" "$required") |
| 62 | + if [ "$size" = "MISSING" ]; then |
| 63 | + echo "::error::${pkg_name} is missing ${required} in published tarball" |
| 64 | + FAILED=1 |
| 65 | + elif [ "$size" = "0" ]; then |
| 66 | + echo "::error::${pkg_name} ${required} is 0 bytes" |
| 67 | + FAILED=1 |
| 68 | + fi |
| 69 | + done |
| 70 | + done |
| 71 | + if [ "$FAILED" = "1" ]; then |
| 72 | + echo "Pre-publish dist validation failed. Refusing to publish empty or incomplete tarballs." |
| 73 | + exit 1 |
| 74 | + fi |
| 75 | + echo "All packages validated: required dist/ artifacts present and non-empty." |
| 76 | + - run: npx changeset publish |
| 77 | + env: |
| 78 | + NPM_CONFIG_PROVENANCE: 'true' |
| 79 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments