v0.2.0 #2
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: | |
| release: | |
| types: [published] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository_owner }}/trmnl-ha | |
| CACHE_REPO: ${{ github.repository_owner }}/trmnl-ha-cache | |
| jobs: | |
| lint-and-test: | |
| name: Lint & Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Cache Bun dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.bun/install/cache | |
| key: bun-${{ runner.os }}-${{ hashFiles('trmnl-ha/ha-trmnl/bun.lock') }} | |
| restore-keys: bun-${{ runner.os }}- | |
| - name: Install GraphicsMagick | |
| run: sudo apt-get update && sudo apt-get install -y graphicsmagick | |
| - name: Install dependencies | |
| working-directory: trmnl-ha/ha-trmnl | |
| run: bun install | |
| - name: Run ESLint | |
| working-directory: trmnl-ha/ha-trmnl | |
| run: bun run lint | |
| - name: Create test options file | |
| working-directory: trmnl-ha/ha-trmnl | |
| run: cp options-dev.json.example options-dev.json | |
| - name: Run tests | |
| working-directory: trmnl-ha/ha-trmnl | |
| run: MOCK_HA=true bun test | |
| build-and-push: | |
| name: Build & Push (${{ matrix.arch }}) | |
| runs-on: ubuntu-latest | |
| needs: [lint-and-test] | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| arch: amd64 | |
| - platform: linux/arm64 | |
| arch: aarch64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version from release tag | |
| id: version | |
| run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT | |
| # NOTE: docker/metadata-action intelligently handles latest tag: | |
| # - Only applies 'latest' if this is the highest semver AND not a prerelease | |
| # - Skips 'latest' for prereleases (alpha, beta, rc) and older version hotfixes | |
| - name: Generate Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.arch }} | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | |
| # NOTE: Uses registry cache from CI builds - no rebuild if layers unchanged! | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: trmnl-ha | |
| platforms: ${{ matrix.platform }} | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: | | |
| type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_REPO }}:${{ matrix.arch }} | |
| type=gha,scope=build-${{ matrix.arch }} | |
| cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_REPO }}:${{ matrix.arch }},mode=max | |
| build-args: | | |
| BUILD_VERSION=${{ steps.version.outputs.version }} | |
| provenance: false |