add badges #13
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 and publish the snapcast docker image | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| build-and-push-image: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| attestations: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Read version from file | |
| id: version | |
| run: echo "SNAPCAST_FULL_VERSION=$(cat version.txt)" >> $GITHUB_ENV | |
| - name: Use version | |
| run: echo "The version is $SNAPCAST_FULL_VERSION" | |
| - name: Compute build arguments | |
| id: compute_args | |
| run: | | |
| UPSTREAM_TAG="${SNAPCAST_FULL_VERSION%-*}" | |
| SNAPCAST_VERSION1="${UPSTREAM_TAG#v}" | |
| SNAPCAST_VERSION2="${SNAPCAST_FULL_VERSION#v}" | |
| for VAR in SNAPCAST_FULL_VERSION UPSTREAM_TAG SNAPCAST_VERSION1 SNAPCAST_VERSION2; do | |
| echo "${VAR}=${!VAR}" >> $GITHUB_OUTPUT | |
| done | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| # Build Docker Images (amd64 and arm64) | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Extract metadata for Docker | |
| id: meta | |
| uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ github.repository }} | |
| # E.g. tag v1.2.0 produces 3 tags: '1.2.0', '1.2', and 'latest' | |
| # https://github.com/docker/metadata-action?tab=readme-ov-file#semver | |
| tags: | | |
| type=semver,pattern={{version}} | |
| - name: Build and push Docker image | |
| id: push | |
| uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/aarch64 | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ github.repository }}:nightly | |
| labels: "nightly" | |
| build-args: | | |
| SNAPCAST_VERSION1=${{ steps.compute_args.outputs.SNAPCAST_VERSION1 }} | |
| SNAPCAST_VERSION2=${{ steps.compute_args.outputs.SNAPCAST_VERSION2 }} | |
| - name: Generate artifact attestation | |
| uses: actions/attest-build-provenance@v1 | |
| with: | |
| subject-name: ${{ env.REGISTRY }}/${{ github.repository }} | |
| subject-digest: ${{ steps.push.outputs.digest }} | |
| push-to-registry: true |