|
| 1 | +name: Auto Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - uses: actions/setup-node@v4 |
| 17 | + with: |
| 18 | + node-version: '18' |
| 19 | + cache: 'npm' |
| 20 | + |
| 21 | + - name: Install dependencies |
| 22 | + run: | |
| 23 | + echo "📦 Installing dependencies..." |
| 24 | + if ! npm ci; then |
| 25 | + echo "❌ Failed to install dependencies" >&2 |
| 26 | + exit 1 |
| 27 | + fi |
| 28 | + echo "✅ Dependencies installed successfully" |
| 29 | +
|
| 30 | + - name: Build with error handling |
| 31 | + run: | |
| 32 | + echo "🔨 Building release artifacts..." |
| 33 | + if ! npm run build:all; then |
| 34 | + echo "❌ Build failed" >&2 |
| 35 | + exit 1 |
| 36 | + fi |
| 37 | + echo "✅ Build completed successfully" |
| 38 | +
|
| 39 | + - name: Validate build outputs |
| 40 | + run: | |
| 41 | + echo "🔍 Validating build outputs..." |
| 42 | + validation_failed=false |
| 43 | +
|
| 44 | + for file in dist/auto-image.{standalone,userscript,bookmarklet}.js dist/auto-image.bookmarklet.txt; do |
| 45 | + if [[ ! -f "$file" ]]; then |
| 46 | + echo "❌ Missing file: $file" >&2 |
| 47 | + validation_failed=true |
| 48 | + elif [[ ! -s "$file" ]]; then |
| 49 | + echo "❌ Empty file: $file" >&2 |
| 50 | + validation_failed=true |
| 51 | + else |
| 52 | + size=$(stat -c%s "$file" 2>/dev/null || echo 0) |
| 53 | + if [[ $size -lt 100 ]]; then |
| 54 | + echo "⚠️ Suspiciously small file: $file ($size bytes)" >&2 |
| 55 | + validation_failed=true |
| 56 | + else |
| 57 | + echo "✅ Valid: $file ($size bytes)" |
| 58 | + fi |
| 59 | + fi |
| 60 | + done |
| 61 | +
|
| 62 | + if [[ "$validation_failed" == "true" ]]; then |
| 63 | + echo "❌ Build validation failed" >&2 |
| 64 | + exit 1 |
| 65 | + fi |
| 66 | +
|
| 67 | + echo "✅ All build outputs validated successfully" |
| 68 | +
|
| 69 | + - name: Generate version tag |
| 70 | + id: version |
| 71 | + run: | |
| 72 | + VERSION="v$(date -u +%Y.%m.%d-%H%M%S)" |
| 73 | + echo "tag=$VERSION" >> $GITHUB_OUTPUT |
| 74 | + echo "Generated version: $VERSION" |
| 75 | +
|
| 76 | + - name: Create Release |
| 77 | + env: |
| 78 | + GH_TOKEN: ${{ github.token }} |
| 79 | + run: | |
| 80 | + echo "🚀 Creating release ${{ steps.version.outputs.tag }}..." |
| 81 | +
|
| 82 | + if ! gh release create ${{ steps.version.outputs.tag }} \ |
| 83 | + --title "Auto Release ${{ steps.version.outputs.tag }}" \ |
| 84 | + --notes "Automated release from ${{ github.ref_name }} branch |
| 85 | +
|
| 86 | + Commit: ${{ github.sha }} |
| 87 | +
|
| 88 | + **Stable Direct URLs (raw files):** |
| 89 | + - https://github.com/Staninna/WPlace-AutoBOT/releases/latest/download/auto-image.standalone.js |
| 90 | + - https://github.com/Staninna/WPlace-AutoBOT/releases/latest/download/auto-image.userscript.js |
| 91 | + - https://github.com/Staninna/WPlace-AutoBOT/releases/latest/download/auto-image.bookmarklet.js |
| 92 | + - https://github.com/Staninna/WPlace-AutoBOT/releases/latest/download/auto-image.bookmarklet.txt |
| 93 | +
|
| 94 | + **Files included:** |
| 95 | + - \`auto-image.standalone.js\` - Standalone version |
| 96 | + - \`auto-image.userscript.js\` - Userscript version |
| 97 | + - \`auto-image.bookmarklet.js\` - Bookmarklet JavaScript |
| 98 | + - \`auto-image.bookmarklet.txt\` - Bookmarklet text" \ |
| 99 | + dist/auto-image.standalone.js \ |
| 100 | + dist/auto-image.userscript.js \ |
| 101 | + dist/auto-image.bookmarklet.js \ |
| 102 | + dist/auto-image.bookmarklet.txt; then |
| 103 | + echo "❌ Failed to create release" >&2 |
| 104 | + exit 1 |
| 105 | + fi |
| 106 | +
|
| 107 | + echo "✅ Release ${{ steps.version.outputs.tag }} created successfully" |
0 commit comments