Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Release

Release #205

Workflow file for this run

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 }}"}'