Skip to content

Automatic Generate #1151

Automatic Generate

Automatic Generate #1151

name: Automatic Generate
on:
schedule:
- cron: "0 5 * * *"
workflow_dispatch:
jobs:
generate_package:
runs-on: "ubuntu-latest"
outputs:
current_ha_version: ${{ steps.current-ha-version.outputs.current-ha-version }}
new_ha_version: ${{ steps.new-ha-version.outputs.new-ha-version }}
need_to_release: ${{ steps.need-to-release.outputs.need-to-release }}
steps:
- name: checkout repo content
uses: actions/checkout@v4
- name: store current ha version
id: current-ha-version
run: echo "::set-output name=current-ha-version::$(cat ha_version)"
- name: setup python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: install dependencies
run: pip install -r requirements_generate.txt
- name: Install phacc for current versions
run: pip install -e .
- name: execute generate package
run: |
export PYTHONPATH=$PYTHONPATH:$(pwd)
python generate_phacc/generate_phacc.py
- name: store new ha version
id: new-ha-version
run: echo "::set-output name=new-ha-version::$(cat ha_version)"
- name: check need to release
id: need-to-release
run: |
if [[ "${{ steps.current-ha-version.outputs.current-ha-version}}" == "${{ steps.new-ha-version.outputs.new-ha-version }}" ]]; then
echo "::set-output name=need-to-release::false"
else
echo "::set-output name=need-to-release::true"
fi
- name: list files
run: ls -a
- name: publish artifact
uses: actions/upload-artifact@v4
with:
name: generated-package
path: |
./
!**/*.pyc
!tmp_dir/
!.git/
if-no-files-found: error
test:
needs: generate_package
runs-on: "ubuntu-latest"
if: needs.generate_package.outputs.need_to_release == 'true'
strategy:
matrix:
python-version: ['3.12', '3.13']
steps:
- name: checkout repo content
uses: actions/checkout@v4
- name: download artifact
uses: actions/download-artifact@v4
with:
name: generated-package
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
- name: Test with pytest
run: |
pytest
make_release:
needs: [generate_package, test]
runs-on: "ubuntu-latest"
if: needs.generate_package.outputs.need_to_release == 'true'
steps:
- uses: actions/checkout@v4
- name: download artifact
uses: actions/download-artifact@v4
with:
name: generated-package
- name: need_to_release_print
run: "echo ${{ needs.generate_package.outputs.need_to_release }}"
- id: next_version
uses: zwaldowski/semver-release-action@v4
with:
dry_run: true
bump: patch
github_token: ${{ secrets.REPO_SCOPED_TOKEN }}
- run: echo "${{ steps.next_version.outputs.version }}" > version
- run: echo "${{ steps.next_version.outputs.version }}"
- id: git_commit
run: |
git config user.name 'Matthew Flamm'
git config user.email '[email protected]'
git add .
git commit -m "Bump version"
git push
echo "::set-output name=sha::$(git rev-parse HEAD)"
- uses: zwaldowski/semver-release-action@v4
with:
github_token: ${{ secrets.REPO_SCOPED_TOKEN }}
sha: ${{ steps.git_commit.outputs.sha }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
with:
tag_name: ${{ steps.next_version.outputs.version }}
release_name: Release ${{ steps.next_version.outputs.version }}
body: |
Automatic release
homeassistant version: ${{ needs.generate_package.outputs.new_ha_version }}
draft: false
prerelease: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build
run: |
python setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}