This repository has been archived by the owner on Nov 7, 2024. It is now read-only.
Release #205
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: | |
release_node: | |
name: π Release Node | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: write | |
pull-requests: write | |
id-token: write | |
outputs: | |
previous-version: ${{ steps.publish.outputs.previous-version }} | |
released-version: ${{ steps.publish.outputs.released-version }} | |
released-sha: ${{ steps.publish.outputs.released-sha }} | |
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]" | |
# setup | |
- name: π Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '${{ env.NODE_VERSION }}' | |
cache: 'npm' | |
registry-url: 'https://registry.npmjs.org/' | |
# caching | |
- name: π Set up nx cache | |
uses: actions/[email protected] | |
with: | |
path: .nx | |
key: ${{ runner.os }}-nx-cache | |
# build | |
- name: π Install dependencies | |
run: npm ci | |
- name: βοΈ Lint | |
run: | | |
npm run lint | |
npm run prettier | |
- name: π Test | |
run: npm test | |
- name: π οΈ Build | |
run: npm run build | |
# release | |
- name: π Publish Node | |
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" | |
echo "released-sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | |
release_docker: | |
needs: [release_node] | |
if: needs.release_node.outputs.previous-version != needs.release_node.outputs.released-version | |
name: π Release Docker | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- name: β€΅οΈ Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ needs.release_node.outputs.released-sha }} | |
# setup | |
- name: π Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '${{ env.NODE_VERSION }}' | |
cache: 'npm' | |
- 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 }} | |
# caching | |
- name: π Set up nx cache | |
uses: actions/[email protected] | |
with: | |
path: .nx | |
key: ${{ runner.os }}-nx-cache | |
- name: π Set up docker cache | |
id: cache | |
uses: actions/[email protected] | |
with: | |
path: /tmp/.docker-cache | |
key: docker-${{ github.sha }} | |
restore-keys: | | |
docker | |
# release | |
- name: π Install dependencies | |
run: npm ci | |
- name: π Publish Docker | |
env: | |
GITHUB_REPO_URL: ${{ github.server_url }}/${{ github.repository }} | |
GITHUB_RUN_ID: ${{ github.run_id }} | |
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }} | |
DOCKER_LOCAL_CACHE_FROM: /tmp/.docker-cache | |
DOCKER_LOCAL_CACHE_TO: /tmp/.docker-cache-new | |
DOCKER_PLATFORM: linux/amd64,linux/arm/v7,linux/arm64/v8 | |
run: | | |
npm run release-docker | |
# tear down | |
- name: π Swap docker build cache | |
run: | | |
rm -rf /tmp/.docker-cache | |
mv /tmp/.docker-cache-new /tmp/.docker-cache | |
notify: | |
needs: [release_node] | |
if: needs.release_node.outputs.previous-version != needs.release_node.outputs.released-version | |
name: π Notify | |
runs-on: ubuntu-latest | |
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.release_node.outputs.released-version }}"}' |