|
| 1 | +name: Release to npm |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + id-token: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Setup Node.js |
| 23 | + uses: actions/setup-node@v4 |
| 24 | + with: |
| 25 | + node-version: '20' |
| 26 | + registry-url: 'https://registry.npmjs.org' |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: npm ci |
| 30 | + |
| 31 | + - name: Run tests |
| 32 | + run: npm run test:coverage:check |
| 33 | + |
| 34 | + - name: Build bundles |
| 35 | + run: npm run build |
| 36 | + |
| 37 | + - name: Verify build outputs |
| 38 | + run: | |
| 39 | + echo "Checking build outputs..." |
| 40 | + ls -la dist/ |
| 41 | +
|
| 42 | + for file in jss.min.js jss.min.js.map jss.esm.js jss.esm.js.map jss.cjs.js jss.cjs.js.map; do |
| 43 | + if [ ! -f "dist/$file" ]; then |
| 44 | + echo "ERROR: Missing dist/$file" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | + done |
| 48 | +
|
| 49 | + echo "All build outputs verified!" |
| 50 | +
|
| 51 | + - name: Publish to npm |
| 52 | + run: npm publish --provenance --access public |
| 53 | + env: |
| 54 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 55 | + |
| 56 | + - name: Get previous tag |
| 57 | + id: prev_tag |
| 58 | + run: | |
| 59 | + PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") |
| 60 | + echo "tag=$PREV_TAG" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + - name: Generate release notes |
| 63 | + id: release_notes |
| 64 | + run: | |
| 65 | + CURRENT_TAG="${GITHUB_REF_NAME}" |
| 66 | + PREV_TAG="${{ steps.prev_tag.outputs.tag }}" |
| 67 | +
|
| 68 | + echo "Current tag: $CURRENT_TAG" |
| 69 | + echo "Previous tag: $PREV_TAG" |
| 70 | +
|
| 71 | + if [ -n "$PREV_TAG" ]; then |
| 72 | + COMMITS=$(git log ${PREV_TAG}..${CURRENT_TAG} --pretty=format:"- %s" --no-merges) |
| 73 | + else |
| 74 | + COMMITS=$(git log --pretty=format:"- %s" --no-merges) |
| 75 | + fi |
| 76 | +
|
| 77 | + # Write to file for multi-line handling |
| 78 | + echo "## What's Changed" > release_notes.md |
| 79 | + echo "" >> release_notes.md |
| 80 | + echo "$COMMITS" >> release_notes.md |
| 81 | + echo "" >> release_notes.md |
| 82 | + echo "---" >> release_notes.md |
| 83 | + echo "" >> release_notes.md |
| 84 | + echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${CURRENT_TAG}" >> release_notes.md |
| 85 | +
|
| 86 | + cat release_notes.md |
| 87 | +
|
| 88 | + - name: Create GitHub Release |
| 89 | + uses: softprops/action-gh-release@v2 |
| 90 | + with: |
| 91 | + body_path: release_notes.md |
| 92 | + files: | |
| 93 | + dist/jss.min.js |
| 94 | + dist/jss.min.js.map |
| 95 | + dist/jss.esm.js |
| 96 | + dist/jss.esm.js.map |
| 97 | + dist/jss.cjs.js |
| 98 | + dist/jss.cjs.js.map |
| 99 | + env: |
| 100 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments