Merge release v1.3.1 #234
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: Build and Deploy Hame Relay | |
| on: | |
| push: | |
| branches: [ "main", "develop" ] | |
| tags: [ "*.*.*" ] | |
| pull_request: | |
| branches: [ "main", "develop" ] | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run Prettier | |
| run: npm run lint | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test | |
| build: | |
| needs: [lint, test] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| - platform: linux/arm64 | |
| - platform: linux/arm/v7 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Create certificates directory | |
| run: mkdir -p certs | |
| - name: Write certificates to files | |
| run: | | |
| echo "${{ secrets.CA_CERTIFICATE }}" > certs/ca.crt | |
| echo "${{ secrets.CLIENT_CERTIFICATE_2024 }}" > certs/hame-2024.crt | |
| echo "${{ secrets.CLIENT_KEY_2024 }}" > certs/hame-2024.key | |
| echo "${{ secrets.HAME_2024_URL }}" > certs/hame-2024-url | |
| echo "${{ secrets.CLIENT_CERTIFICATE_2025 }}" > certs/hame-2025.crt | |
| echo "${{ secrets.CLIENT_KEY_2025 }}" > certs/hame-2025.key | |
| echo "${{ secrets.HAME_2025_URL }}" > certs/hame-2025-url | |
| echo "${{ secrets.TOPIC_ENCRYPTION_KEY_2025 }}" > certs/hame-2025-topic-encryption-key | |
| shell: bash | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - id: lower-repo | |
| run: | | |
| echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=raw,value=next,enable=${{ github.ref == 'refs/heads/develop' }} | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| - name: Log in to 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: Build and push by digest | |
| id: build | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - name: Set platform name | |
| id: platform | |
| run: | | |
| SAFE_PLATFORM=$(echo "${{ matrix.platform }}" | sed 's|/|-|g') | |
| echo "name=$SAFE_PLATFORM" >> $GITHUB_OUTPUT | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ steps.platform.outputs.name }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge-artifacts: | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| needs: [build] | |
| steps: | |
| - name: Merge Artifacts | |
| uses: actions/upload-artifact/merge@v4 | |
| with: | |
| name: digests | |
| pattern: digests-* | |
| merge: | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| needs: [merge-artifacts] | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: digests | |
| path: /tmp/digests | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - id: lower-repo | |
| run: | | |
| echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> $GITHUB_OUTPUT | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=raw,value=next,enable=${{ github.ref == 'refs/heads/develop' }} | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| - name: Log in to Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create manifest list and push | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }}@sha256:%s ' *) | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.IMAGE_NAME }}:${{ steps.meta.outputs.version }} | |
| build-addon: | |
| needs: [lint, test] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| - platform: linux/arm64 | |
| - platform: linux/arm/v7 | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Create certificates directory | |
| run: mkdir -p certs | |
| - name: Write certificates to files | |
| run: | | |
| echo "${{ secrets.CA_CERTIFICATE }}" > certs/ca.crt | |
| echo "${{ secrets.CLIENT_CERTIFICATE_2024 }}" > certs/hame-2024.crt | |
| echo "${{ secrets.CLIENT_KEY_2024 }}" > certs/hame-2024.key | |
| echo "${{ secrets.HAME_2024_URL }}" > certs/hame-2024-url | |
| echo "${{ secrets.CLIENT_CERTIFICATE_2025 }}" > certs/hame-2025.crt | |
| echo "${{ secrets.CLIENT_KEY_2025 }}" > certs/hame-2025.key | |
| echo "${{ secrets.HAME_2025_URL }}" > certs/hame-2025-url | |
| echo "${{ secrets.TOPIC_ENCRYPTION_KEY_2025 }}" > certs/hame-2025-topic-encryption-key | |
| shell: bash | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - id: lower-repo | |
| run: | | |
| echo "ADDON_IMAGE_NAME=${GITHUB_REPOSITORY@L}-addon" >> $GITHUB_OUTPUT | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.ADDON_IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=raw,value=next,enable=${{ github.ref == 'refs/heads/develop' }} | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| - name: Log in to 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: Build and push by digest | |
| id: build | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| file: hassio-addon/Dockerfile | |
| push: ${{ github.event_name != 'pull_request' }} | |
| outputs: type=image,name=${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.ADDON_IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} | |
| build-args: BUILD_FROM=ghcr.io/hassio-addons/base:14.2.2 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| labels: ${{ steps.meta.outputs.labels }} | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/addon-digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/addon-digests/${digest#sha256:}" | |
| - name: Set platform name | |
| id: platform | |
| run: | | |
| SAFE_PLATFORM=$(echo "${{ matrix.platform }}" | sed 's|/|-|g') | |
| echo "name=$SAFE_PLATFORM" >> $GITHUB_OUTPUT | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: addon-digests-${{ steps.platform.outputs.name }} | |
| path: /tmp/addon-digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge-addon-artifacts: | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| needs: [build-addon] | |
| steps: | |
| - name: Merge Artifacts | |
| uses: actions/upload-artifact/merge@v4 | |
| with: | |
| name: addon-digests | |
| pattern: addon-digests-* | |
| merge-addon: | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| needs: [merge-addon-artifacts] | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: addon-digests | |
| path: /tmp/addon-digests | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - id: lower-repo | |
| run: | | |
| echo "ADDON_IMAGE_NAME=${GITHUB_REPOSITORY@L}-addon" >> $GITHUB_OUTPUT | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.ADDON_IMAGE_NAME }} | |
| tags: | | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=raw,value=next,enable=${{ github.ref == 'refs/heads/develop' }} | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| - name: Log in to Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create manifest list and push | |
| working-directory: /tmp/addon-digests | |
| run: | | |
| docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf '${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.ADDON_IMAGE_NAME }}@sha256:%s ' *) | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ steps.lower-repo.outputs.ADDON_IMAGE_NAME }}:${{ steps.meta.outputs.version }} |