Skip to content

Commit

Permalink
Make automatic (#91)
Browse files Browse the repository at this point in the history
* List files

* Path fix

* Test job

* Typo

* Quoting

* Less files

* Skip .git

* Add tests

* Fully automatic

* Only release on success

* Add ha_version file

* test for need to release

* fix need-to-release

* change ha_version

* try job level if for release

* temporary test for not running release

* use different comparison

* now try releasing

* also don't run test if we aren't releasing

* actually do release
  • Loading branch information
MatthewFlamm authored Nov 5, 2021
1 parent 422b42f commit 89d9f8b
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 112 deletions.
110 changes: 108 additions & 2 deletions .github/workflows/automatic_generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ on:
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:
- uses: "actions/checkout@v2"
- name: checkout repo content
uses: actions/checkout@v2
- 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@v2
with:
Expand All @@ -23,9 +29,109 @@ jobs:
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@v2
with:
name: generated-package
path: ~/pytest_homeassistant_custom_component/
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 }}
strategy:
matrix:
python-version: [3.8, 3.9]
steps:
- name: checkout repo content
uses: actions/checkout@v2
- name: download artifact
uses: actions/download-artifact@v2
with:
name: generated-package
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
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 }}
steps:
- uses: actions/checkout@v2
- name: download artifact
uses: actions/download-artifact@v2
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@v2
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 }}"
- run: |
git config user.name 'Matthew Flamm'
git config user.email '[email protected]'
git add .
git commit -m "Bump version"
git push
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_ENV
- uses: zwaldowski/semver-release-action@v2
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
draft: false
prerelease: false
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
2 changes: 2 additions & 0 deletions generate_phacc/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@

LICENSE_FILE_HA = "LICENSE.md"
LICENSE_FILE_NEW = "LICENSE_HA_CORE.md"

HA_VERSION_FILE = "ha_version"
Loading

0 comments on commit 89d9f8b

Please sign in to comment.