Bump the all group across 1 directory with 11 updates #294
This file contains 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 | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
tags: | |
- "20*" | |
branches: | |
- main | |
paths: | |
- "**/*.rs" | |
- "addon/**" | |
- "**/Cargo.*" | |
- ".github/workflows/build.yml" | |
- ".cargo/config.toml" | |
- "scripts/build-cross.sh" | |
- "scripts/build-docker.sh" | |
- "Dockerfile" | |
- ".dockerignore" | |
env: | |
IMAGE: ghcr.io/wez/govee2mqtt | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm/v7 | |
- linux/arm64 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Docker meta | |
if: ${{ github.event_name != 'pull_request' }} | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE }} | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' }} | |
type=ref,event=pr | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: https://ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Install Rust" | |
uses: dtolnay/rust-toolchain@stable | |
- name: "Install cross from Cargo" | |
uses: baptiste0928/cargo-install@v3 | |
with: | |
crate: "cross" | |
- name: Build executable | |
run: ./scripts/build-cross.sh ${{ matrix.platform }} | |
- name: Build No Push | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile | |
platforms: ${{ matrix.platform }} | |
push: false | |
- name: Build and push by digest | |
if: ${{ github.event_name != 'pull_request' }} | |
id: build | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile | |
platforms: ${{ matrix.platform }} | |
labels: ${{ steps.meta.outputs.labels }} | |
push: ${{ github.event_name != 'pull_request' }} | |
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
- name: Export digest | |
if: ${{ github.event_name != 'pull_request' }} | |
id: digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
echo "DIGEST_NAME=$(echo ${{ matrix.platform }} | sed 's,/,-,g')" >> $GITHUB_OUTPUT | |
- name: Upload digest | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digest-${{ steps.digest.outputs.DIGEST_NAME }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
merge: | |
if: ${{ github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: digest-* | |
merge-multiple: true | |
path: /tmp/digests | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.IMAGE }} | |
tags: | | |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
type=ref,event=branch,enable=${{ github.ref != 'refs/heads/main' }} | |
type=ref,event=tag,enable=${{ github.ref_type == 'tag' }} | |
type=ref,event=pr | |
- name: Login to GHCR | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: https://ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create manifest list and push | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create \ | |
${{ github.event_name == 'pull_request' && '--dry-run' || '' }} \ | |
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.IMAGE }}:${{ steps.meta.outputs.version }} | |
addon: | |
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} | |
runs-on: ubuntu-latest | |
needs: | |
- merge | |
permissions: | |
contents: read | |
id-token: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: https://ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Apply tag to version | |
run: ./scripts/apply-tag.sh | |
- name: Build and Publish Home Assistant Add On | |
uses: home-assistant/builder@master | |
with: | |
args: | | |
--all \ | |
--cosign \ | |
--target /data/addon |