Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use matrix builds #16

Merged
merged 2 commits into from
Oct 25, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 48 additions & 19 deletions .github/workflows/builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,86 @@ on:
- go.mod

env:
BUILD_NAME: observer # This needs to match the key in the version file
BUILD_TYPE: plugin # Can be plugin, core, supervisor or generic
BUILD_NAME: observer
BUILD_TYPE: plugin

jobs:
build:
name: Build plugin
init:
name: Initialize build
runs-on: ubuntu-latest
outputs:
architectures: ${{ steps.info.outputs.architectures }}
version: ${{ steps.version.outputs.version }}
channel: ${{ steps.version.outputs.channel }}
publish: ${{ steps.version.outputs.publish }}
steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Get information
id: info
uses: home-assistant/actions/helpers/info@info-helper
pvizeli marked this conversation as resolved.
Show resolved Hide resolved

- name: Get version
id: version
uses: home-assistant/actions/helpers/version@master
with:
type: ${{ env.BUILD_TYPE }}

- name: Initialize git
if: steps.version.outputs.publish == 'true'
uses: home-assistant/actions/helpers/git-init@master
with:
name: ${{ secrets.GIT_NAME }}
email: ${{ secrets.GIT_EMAIL }}
token: ${{ secrets.GIT_TOKEN }}

build:
name: Build ${{ matrix.arch }} plugin
needs: init
runs-on: ubuntu-latest
strategy:
matrix:
arch: ${{ fromJson(needs.init.outputs.architectures) }}
steps:
- name: Checkout the repository
uses: actions/checkout@v2

- name: Login to DockerHub
if: steps.version.outputs.publish == 'true'
if: needs.init.outputs.publish == 'true'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set build arguments
if: steps.version.outputs.publish == 'false'
if: needs.init.outputs.publish == 'false'
run: echo "BUILD_ARGS=--test" >> $GITHUB_ENV

- name: Build plugin
uses: home-assistant/[email protected]
with:
args: |
$BUILD_ARGS \
--all \
--${{ matrix.arch }} \
--target /data \
--generic ${{ steps.version.outputs.version }}
--generic ${{ needs.init.outputs.version }}

version:
name: Update version
needs: ["init", "build"]
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
if: needs.init.outputs.publish == 'true'
uses: actions/checkout@v2

- name: Initialize git
if: needs.init.outputs.publish == 'true'
Copy link
Member Author

@ludeeus ludeeus Oct 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition could be moved to the job instead of for each step, but then the checks overview on the PR details would not be collapsed since one job was skipped, this makes it look cleaner.

uses: home-assistant/actions/helpers/git-init@master
with:
name: ${{ secrets.GIT_NAME }}
email: ${{ secrets.GIT_EMAIL }}
token: ${{ secrets.GIT_TOKEN }}

- name: Update version file
if: steps.version.outputs.publish == 'true'
if: needs.init.outputs.publish == 'true'
uses: home-assistant/actions/helpers/version-push@master
with:
key: ${{ env.BUILD_NAME }}
version: ${{ steps.version.outputs.version }}
channel: ${{ steps.version.outputs.channel }}
version: ${{ needs.init.outputs.version }}
channel: ${{ needs.init.outputs.channel }}