This repository has been archived by the owner on Nov 7, 2024. It is now read-only.
Release #191
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: Release | |
on: | |
schedule: | |
- cron: '0 18 * * FRI' | |
workflow_dispatch: | |
env: | |
CI: 'true' | |
NODE_VERSION: '20.x' | |
jobs: | |
validate: | |
name: π οΈ Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: β€΅οΈ Checkout | |
uses: actions/checkout@v4 | |
- name: π Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '${{ env.NODE_VERSION }}' | |
cache: 'npm' | |
- name: π Install dependencies | |
run: npm ci | |
- name: βοΈ Lint | |
run: npm run lint | |
- name: π οΈ Build | |
run: npm run build | |
- name: π Test | |
run: npm test | |
node: | |
name: π Release Node | |
needs: [validate] | |
runs-on: ubuntu-latest | |
outputs: | |
previous-version: ${{ steps.publish.outputs.previous-version }} | |
released-version: ${{ steps.publish.outputs.released-version }} | |
dist-tag: latest | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
id-token: write | |
steps: | |
- name: β€΅οΈ Checkout | |
uses: actions/checkout@v4 | |
with: | |
ssh-key: ${{ secrets.LERNA_SSH_PRIVATE_KEY }} | |
- name: π€ Configure Git | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "GitHub Actions [Bot]" | |
- name: π Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '${{ env.NODE_VERSION }}' | |
cache: 'npm' | |
registry-url: 'https://registry.npmjs.org/' | |
- name: π Install dependencies | |
run: npm ci | |
- name: π Publish | |
id: publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "previous-version=$(yq -r '.version' lerna.json)" >> "$GITHUB_OUTPUT" | |
npm run release | |
echo "released-version=$(yq -r '.version' lerna.json)" >> "$GITHUB_OUTPUT" | |
docker: | |
name: π Release Docker | |
needs: [node] | |
if: needs.node.outputs.previous-version != needs.node.outputs.released-version | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- name: β€΅οΈ Checkout | |
uses: actions/checkout@v4 | |
- name: π Set up build cache | |
id: cache | |
uses: actions/[email protected] | |
with: | |
path: /tmp/.docker-cache | |
key: docker-${{ github.sha }} | |
restore-keys: | | |
docker | |
- name: π Set up QEMU | |
uses: docker/[email protected] | |
- name: π Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: π Login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: βΉοΈ Compose build flags | |
id: flags | |
run: | | |
echo "version=${{ needs.node.outputs.released-version }}" >> "$GITHUB_OUTPUT" | |
echo "matterbridge-version=$(yq -r '.devDependencies.matterbridge' packages/matterbridge-home-assistant/package.json)" >> "$GITHUB_OUTPUT" | |
- name: π Build | |
uses: docker/[email protected] | |
with: | |
push: true | |
context: packages/matterbridge-home-assistant-docker | |
cache-from: | | |
type=local,src=/tmp/.docker-cache | |
ghcr.io/${{github.repository}}:${{ steps.flags.outputs.version }} | |
ghcr.io/${{github.repository}}:latest | |
cache-to: type=local,mode=max,dest=/tmp/.docker-cache-new | |
tags: | | |
ghcr.io/${{github.repository}}:${{ steps.flags.outputs.version }} | |
ghcr.io/${{github.repository}}:latest | |
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 | |
build-args: | | |
MATTERBRIDGE_HOME_ASSISTANT_VERSION=${{ steps.flags.outputs.version }} | |
MATTERBRIDGE_VERSION=${{ steps.flags.outputs.matterbridge-version }} | |
- name: π Swap build cache | |
run: | | |
rm -rf /tmp/.docker-cache | |
mv /tmp/.docker-cache-new /tmp/.docker-cache | |
dispatch: | |
name: π Repository Dispatch | |
needs: [node, docker] | |
runs-on: ubuntu-latest | |
if: needs.node.outputs.previous-version != needs.node.outputs.released-version | |
steps: | |
- name: π Repository Dispatch | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
token: ${{ secrets.ADDON_DISPATCH_TOKEN }} | |
repository: t0bst4r/matterbridge-home-assistant-addon | |
event-type: release | |
client-payload: '{"latest-version": "${{ needs.node.outputs.released-version }}"}' |