-
Notifications
You must be signed in to change notification settings - Fork 11
140 lines (138 loc) · 4.69 KB
/
automatic_generation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
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.12'
- 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']
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.12'
- 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 }}