Publish Images and Release #36
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: Publish Release | |
# yamllint disable-line rule:truthy | |
on: | |
workflow_dispatch: | |
release: | |
types: [published] | |
# schedule: | |
# - cron: "0 2 * * *" | |
permissions: | |
contents: read | |
jobs: | |
init: | |
name: Initialize build | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.tag.outputs.tag }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get tag | |
id: tag | |
# yamllint disable rule:line-length | |
run: | | |
if [[ "$GITHUB_EVENT_NAME" = "release" ]]; then | |
TAG="${GITHUB_REF#refs/tags/}" | |
else | |
TAG=$(cat package.json | sed -n -E "s/\s*\"version\":\s*\"(.+)\",$/\1/p") | |
today="$(date --utc '+%Y%m%d')" | |
TAG="${TAG}-${today}" | |
BRANCH=${GITHUB_REF#refs/heads/} | |
if [[ "$BRANCH" != "dev" ]]; then | |
TAG="${TAG}-${BRANCH}" | |
fi | |
fi | |
echo "tag=${TAG}" >> $GITHUB_OUTPUT | |
# yamllint enable rule:line-length | |
deploy-docker: | |
name: Build and publish Typedaemon # ${{ matrix.image.title}} | |
if: github.repository == 'matchlighter/typedaemon' | |
permissions: | |
contents: read | |
packages: write | |
runs-on: ubuntu-latest | |
# continue-on-error: ${{ matrix.image.title == 'lint' }} | |
needs: [init] | |
strategy: | |
fail-fast: false | |
# matrix: | |
# image: | |
# - title: "ha-addon" | |
# suffix: "hassio" | |
# target: "hassio" | |
# baseimg: "hassio" | |
# - title: "docker" | |
# suffix: "" | |
# target: "docker" | |
# baseimg: "docker" | |
# - title: "lint" | |
# suffix: "lint" | |
# target: "lint" | |
# baseimg: "docker" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Log in to the GitHub container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate short tags | |
id: tags | |
run: | | |
script/generate_tags.py \ | |
--tag "${{ needs.init.outputs.tag }}" | |
# --suffix "${{ matrix.image.suffix }}" | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm/v7,linux/arm64 | |
# target: ${{ matrix.image.target }} | |
push: true | |
# yamllint disable rule:line-length | |
cache-from: type=registry,ref=ghcr.io/${{ steps.tags.outputs.image }}:cache-${{ steps.tags.outputs.channel }} | |
cache-to: type=registry,ref=ghcr.io/${{ steps.tags.outputs.image }}:cache-${{ steps.tags.outputs.channel }},mode=max | |
# yamllint enable rule:line-length | |
tags: ${{ steps.tags.outputs.tags }} | |
# BASEIMGTYPE=${{ matrix.image.baseimg }} | |
build-args: | | |
BUILD_VERSION=${{ needs.init.outputs.tag }} | |
# deploy-ha-addon-repo: | |
# if: github.repository == 'matchlighter/typedaemon' && github.event_name == 'release' | |
# runs-on: ubuntu-latest | |
# needs: [deploy-docker] | |
# steps: | |
# - name: Trigger Workflow | |
# uses: actions/github-script@v6 | |
# with: | |
# github-token: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }} | |
# script: | | |
# github.rest.actions.createWorkflowDispatch({ | |
# owner: "matchlighter", | |
# repo: "typedaemon-hassio", | |
# workflow_id: "bump-version.yml", | |
# ref: "main", | |
# inputs: { | |
# version: "${{ github.event.release.tag_name }}", | |
# content: ${{ toJSON(github.event.release.body) }} | |
# } | |
# }) |