Release ] : v0.3.2 (#22) #38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ "main", "master", "dev" ] | |
| pull_request: | |
| branches: [ "main", "master", "dev" ] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-and-test: | |
| name: Build & Test (Ubuntu) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| # 1. Checkout the repository code | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| # 2. Extract Dockerfile VERSION and create Floating Minor Version | |
| - name: Read Dockerfile VERSION | |
| id: docker_version | |
| run: | | |
| # Extract the exact version (e.g., "0.3.1") | |
| VERSION=$(grep -E '^ARG VERSION=' Dockerfile | cut -d '=' -f2 | tr -d '"') | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "Found Dockerfile VERSION=$VERSION" | |
| # Extract the minor floating version (e.g., "0.3" from "0.3.1") | |
| MINOR_VERSION=$(echo $VERSION | cut -d. -f1,2) | |
| echo "MINOR_VERSION=$MINOR_VERSION" >> $GITHUB_ENV | |
| echo "Floating Minor Version=$MINOR_VERSION" | |
| # 3. Set Build Date | |
| - name: Set Build Date | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV | |
| echo "Build date: $BUILD_DATE" | |
| # 4. Extract all labels from Dockerfile | |
| - name: Extract Dockerfile Labels | |
| id: docker_labels | |
| run: | | |
| echo "Extracting labels from Dockerfile..." | |
| LABELS=$(grep '^LABEL ' Dockerfile | sed 's/^LABEL //' | tr '\n' ' ') | |
| LABELS="${LABELS//\${VERSION}/${{ env.VERSION }}}" | |
| LABELS="${LABELS//\${BUILD_DATE}/${{ env.BUILD_DATE }}}" | |
| echo "DOCKER_LABELS=$LABELS" >> $GITHUB_ENV | |
| echo "Extracted labels: $LABELS" | |
| # 5. Set up Docker Buildx | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # 6. Build Docker image | |
| - name: Build and Load Docker Image | |
| if: github.ref == 'refs/heads/main' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| load: true | |
| build-args: | | |
| VERSION=${{ env.VERSION }} | |
| BUILD_DATE=${{ env.BUILD_DATE }} | |
| labels: ${{ env.DOCKER_LABELS }} | |
| tags: | | |
| worker-ffmpeg:${{ env.VERSION }} | |
| worker-ffmpeg:${{ env.MINOR_VERSION }} | |
| worker-ffmpeg:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # 7. Log in to GHCR | |
| - name: Log in to GitHub Container Registry | |
| if: github.ref == 'refs/heads/main' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # 8. Download Test Asset | |
| - name: Download Test Asset | |
| run: .github/scripts/download_test_video.sh | |
| # 9. Run Test Suite | |
| - name: Run Test Suite | |
| run: .github/scripts/run_tests.sh | |
| # 10. Push Docker image to GHCR with all tags | |
| - name: Push to GHCR | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| IMAGE_ID=ghcr.io/${{ github.repository }} | |
| IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
| # Apply the exact patch tag, the floating minor tag, and the latest/sha tags | |
| docker tag worker-ffmpeg:${{ env.VERSION }} $IMAGE_ID:${{ env.VERSION }} | |
| docker tag worker-ffmpeg:${{ env.MINOR_VERSION }} $IMAGE_ID:${{ env.MINOR_VERSION }} | |
| docker tag worker-ffmpeg:latest $IMAGE_ID:latest | |
| docker tag worker-ffmpeg:latest $IMAGE_ID:${{ github.sha }} | |
| # Push all tags to the registry | |
| echo "Pushing $IMAGE_ID tags to GHCR..." | |
| docker push $IMAGE_ID:${{ env.VERSION }} | |
| docker push $IMAGE_ID:${{ env.MINOR_VERSION }} | |
| docker push $IMAGE_ID:latest | |
| docker push $IMAGE_ID:${{ github.sha }} |