|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' # Triggers on version tags like v1.0.0, v1.2.3, etc. |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Setup Node.js |
| 19 | + uses: actions/setup-node@v4 |
| 20 | + with: |
| 21 | + node-version: '18' |
| 22 | + cache: 'npm' |
| 23 | + registry-url: 'https://registry.npmjs.org' |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: npm ci |
| 27 | + |
| 28 | + - name: Run tests |
| 29 | + run: npm test |
| 30 | + |
| 31 | + - name: Build library |
| 32 | + run: npm run build |
| 33 | + |
| 34 | + - name: Get version from tag |
| 35 | + id: get_version |
| 36 | + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 37 | + |
| 38 | + - name: Create release notes |
| 39 | + id: release_notes |
| 40 | + run: | |
| 41 | + echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT |
| 42 | + echo "## 🚀 MicroUI v${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_OUTPUT |
| 43 | + echo "" >> $GITHUB_OUTPUT |
| 44 | + echo "### 📦 Assets" >> $GITHUB_OUTPUT |
| 45 | + echo "- **microui.js** (${$(stat -f%z dist/microui.js | numfmt --to=iec)}B) - Development build with source maps" >> $GITHUB_OUTPUT |
| 46 | + echo "- **microui.min.js** (${$(stat -f%z dist/microui.min.js | numfmt --to=iec)}B) - Production build, minified" >> $GITHUB_OUTPUT |
| 47 | + echo "- **microui.esm.js** (${$(stat -f%z dist/microui.esm.js | numfmt --to=iec)}B) - ES modules build" >> $GITHUB_OUTPUT |
| 48 | + echo "" >> $GITHUB_OUTPUT |
| 49 | + echo "### 📊 Bundle Analysis" >> $GITHUB_OUTPUT |
| 50 | + echo "\`\`\`" >> $GITHUB_OUTPUT |
| 51 | + echo "Minified: $(stat -f%z dist/microui.min.js | numfmt --to=iec)B" >> $GITHUB_OUTPUT |
| 52 | + echo "Gzipped: $(gzip -c dist/microui.min.js | wc -c | numfmt --to=iec)B" >> $GITHUB_OUTPUT |
| 53 | + echo "\`\`\`" >> $GITHUB_OUTPUT |
| 54 | + echo "" >> $GITHUB_OUTPUT |
| 55 | + echo "### 🔗 Links" >> $GITHUB_OUTPUT |
| 56 | + echo "- 📚 [Documentation](https://lam0819.github.io/MicroUI/)" >> $GITHUB_OUTPUT |
| 57 | + echo "- 🎮 [Live Examples](https://lam0819.github.io/MicroUI/examples/)" >> $GITHUB_OUTPUT |
| 58 | + echo "- 📋 [API Reference](https://lam0819.github.io/MicroUI/#api-reference)" >> $GITHUB_OUTPUT |
| 59 | + echo "- 🤖 [LLMs.txt](https://lam0819.github.io/MicroUI/llms.txt)" >> $GITHUB_OUTPUT |
| 60 | + echo "" >> $GITHUB_OUTPUT |
| 61 | + echo "### 📥 Installation" >> $GITHUB_OUTPUT |
| 62 | + echo "\`\`\`bash" >> $GITHUB_OUTPUT |
| 63 | + echo "# NPM" >> $GITHUB_OUTPUT |
| 64 | + echo "npm install microui@${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_OUTPUT |
| 65 | + echo "" >> $GITHUB_OUTPUT |
| 66 | + echo "# CDN" >> $GITHUB_OUTPUT |
| 67 | + echo "<script src=\"https://unpkg.com/microui@${{ steps.get_version.outputs.VERSION }}/dist/microui.min.js\"></script>" >> $GITHUB_OUTPUT |
| 68 | + echo "\`\`\`" >> $GITHUB_OUTPUT |
| 69 | + echo "EOF" >> $GITHUB_OUTPUT |
| 70 | + |
| 71 | + - name: Create ZIP archive |
| 72 | + run: | |
| 73 | + mkdir -p release-assets |
| 74 | + cp dist/microui.js release-assets/ |
| 75 | + cp dist/microui.min.js release-assets/ |
| 76 | + cp dist/microui.esm.js release-assets/ |
| 77 | + cp README.md release-assets/ |
| 78 | + cp LICENSE release-assets/ |
| 79 | + cp package.json release-assets/ |
| 80 | + cd release-assets |
| 81 | + zip -r ../microui-v${{ steps.get_version.outputs.VERSION }}.zip . |
| 82 | + cd .. |
| 83 | + |
| 84 | + - name: Create GitHub Release |
| 85 | + id: create_release |
| 86 | + uses: actions/create-release@v1 |
| 87 | + env: |
| 88 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + with: |
| 90 | + tag_name: ${{ github.ref }} |
| 91 | + release_name: MicroUI v${{ steps.get_version.outputs.VERSION }} |
| 92 | + body: ${{ steps.release_notes.outputs.RELEASE_NOTES }} |
| 93 | + draft: false |
| 94 | + prerelease: false |
| 95 | + |
| 96 | + - name: Upload Development Build |
| 97 | + uses: actions/upload-release-asset@v1 |
| 98 | + env: |
| 99 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + with: |
| 101 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 102 | + asset_path: ./dist/microui.js |
| 103 | + asset_name: microui.js |
| 104 | + asset_content_type: application/javascript |
| 105 | + |
| 106 | + - name: Upload Production Build |
| 107 | + uses: actions/upload-release-asset@v1 |
| 108 | + env: |
| 109 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 110 | + with: |
| 111 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 112 | + asset_path: ./dist/microui.min.js |
| 113 | + asset_name: microui.min.js |
| 114 | + asset_content_type: application/javascript |
| 115 | + |
| 116 | + - name: Upload ES Modules Build |
| 117 | + uses: actions/upload-release-asset@v1 |
| 118 | + env: |
| 119 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 120 | + with: |
| 121 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 122 | + asset_path: ./dist/microui.esm.js |
| 123 | + asset_name: microui.esm.js |
| 124 | + asset_content_type: application/javascript |
| 125 | + |
| 126 | + - name: Upload ZIP Archive |
| 127 | + uses: actions/upload-release-asset@v1 |
| 128 | + env: |
| 129 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 130 | + with: |
| 131 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 132 | + asset_path: ./microui-v${{ steps.get_version.outputs.VERSION }}.zip |
| 133 | + asset_name: microui-v${{ steps.get_version.outputs.VERSION }}.zip |
| 134 | + asset_content_type: application/zip |
| 135 | + |
| 136 | + # Uncomment to publish to NPM automatically |
| 137 | + # - name: Publish to NPM |
| 138 | + # run: npm publish |
| 139 | + # env: |
| 140 | + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments