feat: implement RistrettoStorage for improved caching with HTTP middl… #70
Workflow file for this run
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-binaries: | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| goos: linux | |
| goarch: amd64 | |
| cgo: "1" | |
| name: linux-amd64 | |
| - os: macos-latest | |
| goos: darwin | |
| goarch: arm64 | |
| cgo: "1" | |
| name: darwin-arm64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.24' | |
| - name: Install Linux dependencies | |
| if: matrix.os == 'ubuntu-latest' && matrix.cgo == '1' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| gcc \ | |
| pkg-config \ | |
| make \ | |
| nasm \ | |
| yasm \ | |
| git \ | |
| wget \ | |
| tar \ | |
| xz-utils \ | |
| libssl-dev \ | |
| libwebp-dev \ | |
| build-essential | |
| - name: Install macOS dependencies | |
| if: matrix.os == 'macos-latest' && matrix.cgo == '1' && matrix.goarch == 'arm64' | |
| run: | | |
| brew install ffmpeg@7 webp nasm coreutils | |
| - name: Build FFmpeg from source (Linux) | |
| if: matrix.os == 'ubuntu-latest' && matrix.cgo == '1' | |
| run: | | |
| mkdir -p tmp | |
| cd tmp | |
| wget https://ffmpeg.org/releases/ffmpeg-7.0.tar.xz | |
| tar -xf ffmpeg-7.0.tar.xz | |
| cd ffmpeg-7.0 | |
| ./configure \ | |
| --prefix=/tmp/ffmpeg \ | |
| --enable-shared \ | |
| --disable-static \ | |
| --disable-autodetect \ | |
| --disable-programs \ | |
| --disable-doc \ | |
| --disable-postproc \ | |
| --disable-pixelutils \ | |
| --disable-hwaccels \ | |
| --disable-ffprobe \ | |
| --disable-ffplay \ | |
| --enable-openssl \ | |
| --enable-protocol=file,http,hls | |
| make -j$(nproc) | |
| make install | |
| - name: Run tests | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: ${{ matrix.cgo }} | |
| run: | | |
| if [ "${{ matrix.os }}" = "ubuntu-latest" ] && [ "${{ matrix.cgo }}" = "1" ]; then | |
| export CGO_LDFLAGS="-L/tmp/ffmpeg/lib/" | |
| export CGO_CFLAGS="-I/tmp/ffmpeg/include/" | |
| export PKG_CONFIG_PATH="/tmp/ffmpeg/lib/pkgconfig" | |
| elif [ "${{ matrix.os }}" = "macos-latest" ] && [ "${{ matrix.cgo }}" = "1" ]; then | |
| export PKG_CONFIG_PATH="/opt/homebrew/opt/ffmpeg@7/lib/pkgconfig" | |
| fi | |
| go test ./... | |
| - name: Build binary | |
| env: | |
| GOOS: ${{ matrix.goos }} | |
| GOARCH: ${{ matrix.goarch }} | |
| CGO_ENABLED: ${{ matrix.cgo }} | |
| run: | | |
| # Set build environment based on OS and CGO | |
| if [ "${{ matrix.os }}" = "ubuntu-latest" ] && [ "${{ matrix.cgo }}" = "1" ]; then | |
| export CGO_LDFLAGS="-L/tmp/ffmpeg/lib/" | |
| export CGO_CFLAGS="-I/tmp/ffmpeg/include/" | |
| export PKG_CONFIG_PATH="/tmp/ffmpeg/lib/pkgconfig" | |
| elif [ "${{ matrix.os }}" = "macos-latest" ] && [ "${{ matrix.cgo }}" = "1" ]; then | |
| export PKG_CONFIG_PATH="/opt/homebrew/opt/ffmpeg@7/lib/pkgconfig" | |
| fi | |
| # Build the binary | |
| mkdir -p bin | |
| go build -ldflags="-s -w" -o bin/media-proxy-${{ matrix.name }}${{ matrix.ext }} . | |
| # Create sha256 | |
| cd bin | |
| sha256sum media-proxy-${{ matrix.name }}${{ matrix.ext }} > media-proxy-${{ matrix.name }}${{ matrix.ext }}.sha256 | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binary-${{ matrix.name }} | |
| path: bin/ | |
| build-docker-and-release: | |
| needs: build-binaries | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Collect all binaries | |
| run: | | |
| mkdir -p bin | |
| find artifacts -name "media-proxy-*" -type f -exec cp {} bin/ \; | |
| ls -la bin/ | |
| - name: Extract tag name | |
| id: tag | |
| run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=tag | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| labels: | | |
| org.opencontainers.image.title=Media Proxy | |
| org.opencontainers.image.description=A media proxy server with FFmpeg support | |
| org.opencontainers.image.source=https://github.com/${{ github.repository }} | |
| org.opencontainers.image.licenses=MIT | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.tag }} | |
| name: Release ${{ steps.tag.outputs.tag }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| files: bin/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |