Docker build enhancements #8
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: Build Librespot Docker (ARM64) | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| - 'Dockerfile' | |
| - 'docker/**' | |
| - '.github/workflows/**' | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| docker-build: | |
| runs-on: ubuntu-24.04-arm | |
| permissions: | |
| contents: read | |
| packages: write | |
| attestations: write | |
| id-token: write | |
| steps: | |
| - name: Checkout the repository | |
| uses: actions/checkout@v4 | |
| - name: Checkout upstream librespot | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: librespot-org/librespot | |
| path: librespot-source | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| driver: docker-container | |
| - name: Get Librespot version from Cargo.toml | |
| id: version | |
| run: | | |
| VERSION=$(awk -F '"' '/^version/ {print $2; exit}' librespot-source/Cargo.toml) | |
| echo "Found version: $VERSION" | |
| echo "librespot_version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Prepare build context | |
| run: | | |
| cp Dockerfile librespot-source/ | |
| cp -r docker librespot-source/ | |
| echo ".git" > librespot-source/.dockerignore | |
| echo "target" >> librespot-source/.dockerignore | |
| - name: Login to the Container registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=latest | |
| type=sha,prefix=sha- | |
| type=raw,value=${{ steps.version.outputs.librespot_version }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./librespot-source | |
| push: ${{ github.event_name != 'pull_request' }} | |
| provenance: false | |
| file: ./librespot-source/Dockerfile | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=docker-${{ github.workflow }} | |
| cache-to: type=gha,mode=max,scope=docker-${{ github.workflow }} |