|
| 1 | +name: Docker Release |
| 2 | +on: |
| 3 | + release: |
| 4 | + types: [published] |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'docker-rebuild-v*' # Allow manual Docker rebuilds via tags |
| 8 | + |
| 9 | +jobs: |
| 10 | + docker: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Extract version from release or tag |
| 18 | + id: get_version |
| 19 | + run: | |
| 20 | + if [ "${{ github.event_name }}" == "release" ]; then |
| 21 | + # Triggered by release event |
| 22 | + VERSION="${{ github.event.release.tag_name }}" |
| 23 | + VERSION=${VERSION#v} # Remove 'v' prefix |
| 24 | + else |
| 25 | + # Triggered by docker-rebuild-v* tag |
| 26 | + VERSION=${GITHUB_REF#refs/tags/docker-rebuild-v} |
| 27 | + fi |
| 28 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 29 | + echo "Building Docker images for version: $VERSION" |
| 30 | +
|
| 31 | + - name: Extract major and minor versions |
| 32 | + id: versions |
| 33 | + run: | |
| 34 | + VERSION=${{ steps.get_version.outputs.VERSION }} |
| 35 | + MAJOR=$(echo $VERSION | cut -d. -f1) |
| 36 | + MINOR=$(echo $VERSION | cut -d. -f1-2) |
| 37 | + echo "MAJOR=$MAJOR" >> $GITHUB_OUTPUT |
| 38 | + echo "MINOR=$MINOR" >> $GITHUB_OUTPUT |
| 39 | + echo "Semantic versions - Major: $MAJOR, Minor: $MINOR" |
| 40 | +
|
| 41 | + - name: Set up Docker Buildx |
| 42 | + uses: docker/setup-buildx-action@v3 |
| 43 | + |
| 44 | + - name: Log in to Docker Hub |
| 45 | + uses: docker/login-action@v3 |
| 46 | + with: |
| 47 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 48 | + password: ${{ secrets.DOCKER_TOKEN }} |
| 49 | + |
| 50 | + - name: Build and push Docker images |
| 51 | + uses: docker/build-push-action@v5 |
| 52 | + with: |
| 53 | + context: . |
| 54 | + push: true |
| 55 | + tags: | |
| 56 | + unclecode/crawl4ai:${{ steps.get_version.outputs.VERSION }} |
| 57 | + unclecode/crawl4ai:${{ steps.versions.outputs.MINOR }} |
| 58 | + unclecode/crawl4ai:${{ steps.versions.outputs.MAJOR }} |
| 59 | + unclecode/crawl4ai:latest |
| 60 | + platforms: linux/amd64,linux/arm64 |
| 61 | + cache-from: type=gha |
| 62 | + cache-to: type=gha,mode=max |
| 63 | + |
| 64 | + - name: Summary |
| 65 | + run: | |
| 66 | + echo "## 🐳 Docker Release Complete!" >> $GITHUB_STEP_SUMMARY |
| 67 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 68 | + echo "### Published Images" >> $GITHUB_STEP_SUMMARY |
| 69 | + echo "- \`unclecode/crawl4ai:${{ steps.get_version.outputs.VERSION }}\`" >> $GITHUB_STEP_SUMMARY |
| 70 | + echo "- \`unclecode/crawl4ai:${{ steps.versions.outputs.MINOR }}\`" >> $GITHUB_STEP_SUMMARY |
| 71 | + echo "- \`unclecode/crawl4ai:${{ steps.versions.outputs.MAJOR }}\`" >> $GITHUB_STEP_SUMMARY |
| 72 | + echo "- \`unclecode/crawl4ai:latest\`" >> $GITHUB_STEP_SUMMARY |
| 73 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 74 | + echo "### Platforms" >> $GITHUB_STEP_SUMMARY |
| 75 | + echo "- linux/amd64" >> $GITHUB_STEP_SUMMARY |
| 76 | + echo "- linux/arm64" >> $GITHUB_STEP_SUMMARY |
| 77 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 78 | + echo "### 🚀 Pull Command" >> $GITHUB_STEP_SUMMARY |
| 79 | + echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY |
| 80 | + echo "docker pull unclecode/crawl4ai:${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY |
| 81 | + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |
0 commit comments