Skip to content

Commit d559c3e

Browse files
fix: resolve GitHub release asset conflict by using documentation archive
- Change semantic-release to upload single docs-archive.tar.gz instead of individual files - Add scripts/package-docs.sh for creating documentation archives - Update CI/CD workflow to create archive before release - Add docs:package npm script for local documentation packaging - Update .gitignore to exclude documentation archives - Add comprehensive documentation in docs/GITHUB_ASSET_FIX.md This fixes the 'already_exists' error when multiple index.html files in different docs subdirectories caused GitHub asset name conflicts.
1 parent f58a907 commit d559c3e

53 files changed

Lines changed: 294 additions & 47 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci-cd.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
node-version: ${{ env.NODE_VERSION }}
3535

3636
- name: 📦 Setup pnpm
37+
id: pnpm-setup
3738
uses: pnpm/action-setup@v3
3839
with:
3940
version: ${{ env.PNPM_VERSION }}
@@ -43,11 +44,10 @@ jobs:
4344
shell: bash
4445
run: |
4546
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
46-
4747
- name: 💾 Setup pnpm cache
4848
uses: actions/cache@v4
4949
with:
50-
path: ${{ env.STORE_PATH }}
50+
path: ${{ steps.pnpm-setup.outputs.store_path }}
5151
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
5252
restore-keys: |
5353
${{ runner.os }}-pnpm-store-
@@ -318,7 +318,14 @@ jobs:
318318
- name: 📚 Generate fresh documentation
319319
run: pnpm run docs:build
320320

321-
- name: 🚀 Semantic Release
321+
- name: � Create documentation archive
322+
run: |
323+
cd docs
324+
tar -czf ../docs-archive.tar.gz .
325+
cd ..
326+
echo "📦 Documentation archive created: $(du -h docs-archive.tar.gz)"
327+
328+
- name: �🚀 Semantic Release
322329
env:
323330
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
324331
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ test-results/
5454
playwright-report/
5555
playwright/.cache/
5656

57+
# Documentation archives
58+
docs-archive.tar.gz
59+
*.docs.tar.gz
60+

.releaserc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@
6565
"label": "Distribution package"
6666
},
6767
{
68-
"path": "docs/**/*",
69-
"label": "Documentation"
68+
"path": "docs-archive.tar.gz",
69+
"label": "Documentation Archive"
7070
}
7171
],
72-
"successComment": "🎉 This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} 🎉\n\nThe release is available on:\n- [npm package (@latest dist-tag)](https://www.npmjs.com/package/${context.payload.repository.name}/v/${nextRelease.version})\n- [GitHub release](${releases.filter(release => release.pluginName === '@semantic-release/github')[0].url})\n\nYour **[semantic-release](https://github.com/semantic-release/semantic-release)** bot 📦🚀"
72+
"successComment": "🎉 This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} 🎉\n\nThe release is available on:\n- [npm package (@latest dist-tag)](https://www.npmjs.com/package/${context.payload.repository.name}/v/${nextRelease.version})\n- [GitHub release](${releases.filter(release => release.pluginName === '@semantic-release/github')[0].url})\n- [Documentation](https://devalexanderdaza.github.io/crawlee-scraper-toolkit/)\n\nYour **[semantic-release](https://github.com/semantic-release/semantic-release)** bot 📦🚀"
7373
}
7474
],
7575
[

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ pnpm run docs:serve # Available at http://localhost:8080
407407
| `docs:serve` | Serve docs locally with HTTP server |
408408
| `docs:clean` | Clean documentation directory |
409409
| `docs:preview` | Build and serve in one command |
410+
| `docs:package` | Create compressed documentation archive |
410411

411412
## 🚀 Release Process
412413

docs/GITHUB_ASSET_FIX.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Fix GitHub Release Asset Conflict
2+
3+
## Problem
4+
The semantic-release CI/CD pipeline was failing with the error:
5+
```
6+
{"resource":"ReleaseAsset","code":"already_exists","field":"name"}
7+
```
8+
9+
This occurred when trying to upload documentation files as GitHub release assets. The issue was that multiple `index.html` files existed in different subdirectories of the `docs/` folder (e.g., `docs/index.html`, `docs/coverage/index.html`, `docs/coverage/lcov-report/index.html`, etc.), and GitHub treats all files with the same basename as duplicate assets.
10+
11+
## Root Cause
12+
The original semantic-release configuration attempted to upload all files in `docs/**/*` as individual assets:
13+
14+
```json
15+
{
16+
"path": "docs/**/*",
17+
"label": "Documentation"
18+
}
19+
```
20+
21+
When semantic-release processes this glob pattern, it uploads each file individually to GitHub Releases. Since GitHub uses only the basename for asset names (not the full path), multiple files named `index.html` caused conflicts.
22+
23+
## Solution
24+
Changed the asset strategy from uploading individual files to creating a single compressed archive:
25+
26+
### 1. Updated semantic-release configuration (`.releaserc.json`)
27+
```json
28+
{
29+
"path": "docs-archive.tar.gz",
30+
"label": "Documentation Archive"
31+
}
32+
```
33+
34+
### 2. Modified CI/CD workflow (`.github/workflows/ci-cd.yml`)
35+
Added a step to create the documentation archive before semantic-release:
36+
37+
```yaml
38+
- name: 📦 Create documentation archive
39+
run: |
40+
cd docs
41+
tar -czf ../docs-archive.tar.gz .
42+
cd ..
43+
echo "📦 Documentation archive created: $(du -h docs-archive.tar.gz)"
44+
```
45+
46+
### 3. Created packaging script (`scripts/package-docs.sh`)
47+
Added a reusable script for local documentation packaging with:
48+
- Automated documentation generation if needed
49+
- Archive creation with compression
50+
- Size and content reporting
51+
- Error handling and validation
52+
53+
### 4. Added npm script
54+
```json
55+
"docs:package": "./scripts/package-docs.sh"
56+
```
57+
58+
### 5. Updated .gitignore
59+
Added patterns to exclude documentation archives from git:
60+
```
61+
# Documentation archives
62+
docs-archive.tar.gz
63+
*.docs.tar.gz
64+
```
65+
66+
## Benefits
67+
1. **Eliminates asset conflicts**: Single archive file prevents naming conflicts
68+
2. **Smaller release assets**: Compressed archive is more efficient than multiple files
69+
3. **Better download experience**: Users get complete documentation in one download
70+
4. **Consistent naming**: Archive name is predictable and unique
71+
5. **Local tooling**: Developers can package documentation locally for testing
72+
73+
## Usage
74+
- **Local packaging**: `pnpm run docs:package`
75+
- **CI/CD**: Automatic during release process
76+
- **Download**: Single `.tar.gz` file in GitHub releases
77+
78+
## File Structure
79+
```
80+
docs-archive.tar.gz
81+
├── index.html # Main documentation
82+
├── api/ # API documentation
83+
├── coverage/ # Test coverage reports
84+
└── html/ # Generated HTML docs
85+
```
86+
87+
This solution maintains all documentation functionality while eliminating the GitHub asset conflict error.

docs/api.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12212,7 +12212,15 @@
1221212212
},
1221312213
{
1221412214
"kind": "text",
12215-
"text": " | Build and serve in one command |\n\n## 🚀 Release Process\n\nThis project uses **semantic-release** for fully automated versioning and publishing. All releases are handled automatically by CI/CD based on conventional commits.\n\n### 📋 Conventional Commits\n\nUse conventional commit messages to trigger automatic releases:\n\n"
12215+
"text": " | Build and serve in one command |\n| "
12216+
},
12217+
{
12218+
"kind": "code",
12219+
"text": "`docs:package`"
12220+
},
12221+
{
12222+
"kind": "text",
12223+
"text": " | Create compressed documentation archive |\n\n## 🚀 Release Process\n\nThis project uses **semantic-release** for fully automated versioning and publishing. All releases are handled automatically by CI/CD based on conventional commits.\n\n### 📋 Conventional Commits\n\nUse conventional commit messages to trigger automatic releases:\n\n"
1221612224
},
1221712225
{
1221812226
"kind": "code",

docs/api/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ pnpm run docs:serve # Available at http://localhost:8080
411411
| `docs:serve` | Serve docs locally with HTTP server |
412412
| `docs:clean` | Clean documentation directory |
413413
| `docs:preview` | Build and serve in one command |
414+
| `docs:package` | Create compressed documentation archive |
414415

415416
## 🚀 Release Process
416417

docs/api/_media/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ pnpm run docs:serve # Available at http://localhost:8080
411411
| `docs:serve` | Serve docs locally with HTTP server |
412412
| `docs:clean` | Clean documentation directory |
413413
| `docs:preview` | Build and serve in one command |
414+
| `docs:package` | Create compressed documentation archive |
414415

415416
## 🚀 Release Process
416417

docs/api/_media/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ <h1>All files</h1>
176176
<div class='footer quiet pad2 space-top1 center small'>
177177
Code coverage generated by
178178
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
179-
at 2025-06-06T03:29:12.812Z
179+
at 2025-06-06T05:07:48.197Z
180180
</div>
181181
<script src="prettify.js"></script>
182182
<script>

docs/coverage/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ <h1>All files</h1>
176176
<div class='footer quiet pad2 space-top1 center small'>
177177
Code coverage generated by
178178
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
179-
at 2025-06-06T03:29:12.839Z
179+
at 2025-06-06T05:07:48.225Z
180180
</div>
181181
<script src="prettify.js"></script>
182182
<script>

0 commit comments

Comments
 (0)