Skip to content

Commit

Permalink
JH: Fix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
adeepn committed Jul 1, 2024
1 parent bfd37d7 commit 3dbae29
Showing 1 changed file with 59 additions and 34 deletions.
93 changes: 59 additions & 34 deletions .github/workflows/release-jh.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
name: JH Publish Release

# yamllint disable-line rule:truthy
on:
release:
types: [published]
Expand All @@ -18,49 +17,55 @@ jobs:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
branch_build: ${{ steps.tag.outputs.branch_build }}
steps:
- uses: actions/[email protected].1
- uses: actions/[email protected].5
- name: Get tag
id: tag
# yamllint disable rule:line-length
run: |
if [[ "$GITHUB_EVENT_NAME" = "release" ]]; then
TAG="${GITHUB_REF#refs/tags/}"
if [[ "${{ github.event_name }}" = "release" ]]; then
TAG="${{ github.event.release.tag_name}}"
BRANCH_BUILD="false"
else
TAG=$(cat esphome/const.py | sed -n -E "s/^__version__\s+=\s+\"(.+)\"$/\1/p")
today="$(date --utc '+%Y%m%d')"
TAG="${TAG}${today}"
BRANCH=${GITHUB_REF#refs/heads/}
if [[ "$BRANCH" != "dev-jethub" ]]; then
TAG="${TAG}-${BRANCH}"
BRANCH_BUILD="true"
else
BRANCH_BUILD="false"
fi
fi
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "branch_build=${BRANCH_BUILD}" >> $GITHUB_OUTPUT
# yamllint enable rule:line-length

deploy-pypi:
name: Build and publish to PyPi
if: 0 #github.repository == 'jethome-iot/esphome' && github.event_name == 'release'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/[email protected].1
- uses: actions/[email protected].5
- name: Set up Python
uses: actions/setup-python@v5.0.0
uses: actions/setup-python@v5.1.0
with:
python-version: "3.x"
- name: Set up python environment
env:
ESPHOME_NO_VENV: 1
run: |
script/setup
pip install twine
run: script/setup
- name: Build
run: python setup.py sdist bdist_wheel
- name: Upload
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*
run: |-
pip3 install build
python3 -m build
- name: Publish
uses: pypa/[email protected]

deploy-docker:
name: Build ESPHome ${{ matrix.platform }}
Expand All @@ -78,27 +83,26 @@ jobs:
- linux/arm/v7
- linux/arm64
steps:
- uses: actions/[email protected].1
- uses: actions/[email protected].5
- name: Set up Python
uses: actions/setup-python@v5.0.0
uses: actions/setup-python@v5.1.0
with:
python-version: "3.9"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.0.0
uses: docker/setup-buildx-action@v3.3.0
- name: Set up QEMU
if: matrix.platform != 'linux/amd64'
uses: docker/[email protected]

- name: Log in to docker hub
if: 0
uses: docker/login-action@v3.0.0
uses: docker/login-action@v3.1.0
with:
username: ${{ env.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to the GitHub container registry
uses: docker/login-action@v3.0.0
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand Down Expand Up @@ -131,6 +135,19 @@ jobs:
suffix: lint
version: ${{ needs.init.outputs.tag }}

- name: Sanitize platform name
id: sanitize
run: |
echo "${{ matrix.platform }}" | sed 's|/|-|g' > /tmp/platform
echo name=$(cat /tmp/platform) >> $GITHUB_OUTPUT
- name: Upload digests
uses: actions/[email protected]
with:
name: digests-${{ steps.sanitize.outputs.name }}
path: /tmp/digests
retention-days: 1

deploy-manifest:
name: Publish ESPHome ${{ matrix.image.title }} to ${{ matrix.registry }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -158,25 +175,27 @@ jobs:
- ghcr
# - dockerhub
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]

- name: Download digests
uses: actions/download-artifact@v3.0.2
uses: actions/download-artifact@v4.1.7
with:
name: digests-${{ matrix.image.target }}-${{ matrix.registry }}
pattern: digests-*
path: /tmp/digests
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.0.0
uses: docker/setup-buildx-action@v3.3.0

- name: Log in to docker hub
if: matrix.registry == 'dockerhub'
uses: docker/login-action@v3.0.0
uses: docker/login-action@v3.1.0
with:
username: ${{ env.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to the GitHub container registry
if: matrix.registry == 'ghcr'
uses: docker/login-action@v3.0.0
uses: docker/login-action@v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
Expand All @@ -195,28 +214,34 @@ jobs:
done
- name: Create manifest list and push
working-directory: /tmp/digests
working-directory: /tmp/digests/${{ matrix.image.target }}/${{ matrix.registry }}
run: |
docker buildx imagetools create $(jq -Rcnr 'inputs | . / "," | map("-t " + .) | join(" ")' <<< "${{ steps.tags.outputs.tags}}") \
$(printf '${{ steps.tags.outputs.image }}@sha256:%s ' *)
deploy-ha-addon-repo:
if: 0 #github.repository == 'jethome-iot/esphome' && github.event_name == 'release'
if: 0 #github.repository == 'esphome/esphome' && needs.init.outputs.branch_build == 'false'
runs-on: ubuntu-latest
needs: [deploy-manifest]
needs:
- init
- deploy-manifest
steps:
- name: Trigger Workflow
uses: actions/[email protected]
with:
github-token: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }}
script: |
let description = "ESPHome";
if (context.eventName == "release") {
description = ${{ toJSON(github.event.release.body) }};
}
github.rest.actions.createWorkflowDispatch({
owner: "esphome",
owner: "jethome-iot",
repo: "home-assistant-addon",
workflow_id: "bump-version.yml",
ref: "main",
inputs: {
version: "${{ github.event.release.tag_name }}",
content: ${{ toJSON(github.event.release.body) }}
version: "${{ needs.init.outputs.tag }}",
content: description
}
})

0 comments on commit 3dbae29

Please sign in to comment.