|
| 1 | +name: Build dist branch |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + source_ref: |
| 9 | + description: 'Source ref to build from (default: main)' |
| 10 | + required: false |
| 11 | + default: 'main' |
| 12 | + |
| 13 | +jobs: |
| 14 | + build-dist: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout source |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + ref: ${{ inputs.source_ref || 'main' }} |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Setup pnpm |
| 24 | + uses: pnpm/action-setup@v4 |
| 25 | + |
| 26 | + - name: Setup Node.js |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: '20' |
| 30 | + cache: 'pnpm' |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: pnpm install --frozen-lockfile |
| 34 | + |
| 35 | + - name: Get source commit info |
| 36 | + id: source |
| 37 | + run: | |
| 38 | + echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT |
| 39 | + echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
| 40 | + echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT |
| 41 | +
|
| 42 | + - name: Pack packages |
| 43 | + run: | |
| 44 | + # Pack each package (resolves catalog: and workspace: refs) |
| 45 | + for pkg in client parser slidev types; do |
| 46 | + echo "Packing @slidev/$pkg..." |
| 47 | + cd packages/$pkg |
| 48 | + pnpm pack |
| 49 | + cd ../.. |
| 50 | + done |
| 51 | +
|
| 52 | + - name: Prepare dist branch content |
| 53 | + run: | |
| 54 | + mkdir -p dist-content/packages |
| 55 | +
|
| 56 | + # Extract each packed tarball to dist structure |
| 57 | + for pkg in client parser slidev types; do |
| 58 | + echo "Extracting $pkg..." |
| 59 | + mkdir -p dist-content/packages/$pkg |
| 60 | + tar -xzf packages/$pkg/*.tgz -C dist-content/packages/$pkg --strip-components=1 |
| 61 | + done |
| 62 | +
|
| 63 | + # Create root package.json for the dist branch |
| 64 | + cat > dist-content/package.json << 'EOF' |
| 65 | + { |
| 66 | + "name": "@open-athena/slidev-dist", |
| 67 | + "private": true, |
| 68 | + "description": "Dist branch with resolved dependencies for Open-Athena/slidev fork", |
| 69 | + "repository": { |
| 70 | + "type": "git", |
| 71 | + "url": "https://github.com/Open-Athena/slidev" |
| 72 | + } |
| 73 | + } |
| 74 | + EOF |
| 75 | +
|
| 76 | + # Add README |
| 77 | + cat > dist-content/README.md << EOF |
| 78 | + # Slidev Dist Branch |
| 79 | +
|
| 80 | + This branch contains packed versions of Slidev packages with resolved dependencies. |
| 81 | +
|
| 82 | + **Source commit:** ${{ steps.source.outputs.sha }} |
| 83 | + **Built from:** ${{ inputs.source_ref || 'main' }} |
| 84 | +
|
| 85 | + ## Usage |
| 86 | +
|
| 87 | + In your \`package.json\`, use pnpm's git subdirectory syntax: |
| 88 | +
|
| 89 | + \`\`\`json |
| 90 | + { |
| 91 | + "dependencies": { |
| 92 | + "@slidev/cli": "git+https://github.com/Open-Athena/slidev.git?path=/packages/slidev#dist" |
| 93 | + }, |
| 94 | + "pnpm": { |
| 95 | + "overrides": { |
| 96 | + "@slidev/client": "git+https://github.com/Open-Athena/slidev.git?path=/packages/client#dist", |
| 97 | + "@slidev/parser": "git+https://github.com/Open-Athena/slidev.git?path=/packages/parser#dist", |
| 98 | + "@slidev/types": "git+https://github.com/Open-Athena/slidev.git?path=/packages/types#dist" |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | + \`\`\` |
| 103 | +
|
| 104 | + Or pin to a specific commit: |
| 105 | +
|
| 106 | + \`\`\`json |
| 107 | + "@slidev/client": "git+https://github.com/Open-Athena/slidev.git?path=/packages/client#${{ steps.source.outputs.sha }}" |
| 108 | + \`\`\` |
| 109 | + EOF |
| 110 | +
|
| 111 | + - name: Push to dist branch |
| 112 | + run: | |
| 113 | + cd dist-content |
| 114 | +
|
| 115 | + git init |
| 116 | + git config user.name "github-actions[bot]" |
| 117 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 118 | +
|
| 119 | + git add -A |
| 120 | + git commit -m "dist: ${{ steps.source.outputs.message }} |
| 121 | +
|
| 122 | + Source: ${{ steps.source.outputs.sha }} |
| 123 | +
|
| 124 | + 🤖 Generated with GitHub Actions" |
| 125 | +
|
| 126 | + # Force push to dist branch |
| 127 | + git push --force "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" HEAD:dist |
| 128 | +
|
| 129 | + echo "✅ Pushed to dist branch" |
| 130 | + echo "" |
| 131 | + echo "Install with:" |
| 132 | + echo ' "@slidev/client": "git+https://github.com/${{ github.repository }}.git?path=/packages/client#dist"' |
0 commit comments