-
Notifications
You must be signed in to change notification settings - Fork 1
110 lines (101 loc) · 3.89 KB
/
deploy.yml
File metadata and controls
110 lines (101 loc) · 3.89 KB
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Github Deploy
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
release:
types: [published]
concurrency:
group: gh-pages-deploy
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
strategy:
fail-fast: false
matrix:
python-version: ["3.14"]
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: HACS Action
uses: "hacs/action@dcb30e72781db3f207d5236b861172774ab0b485"
with:
category: "integration"
- name: HACS Hassfest
uses: "home-assistant/actions/hassfest@5752577ea7cc5aefb064b0b21432f18fe4d6ba90"
- name: Install uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
sudo apt-get install pngquant
uv sync
- name: Ruff
uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6
- name: Test with pytest
run: |
uv run pytest . --junitxml=junit/test-results-${{ matrix.python-version }}.xml --cov=custom_components.supernotify --cov-report=xml --cov-report=html
- name: Upload pytest test results
uses: actions/upload-artifact@v7
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Generate badges
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
uv run genbadge coverage -i coverage.xml -o badges/coverage.svg
uv run genbadge tests -i junit/test-results-${{ matrix.python-version }}.xml -o badges/tests.svg
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
TEMP_DIR=$(mktemp -d)
cd $TEMP_DIR
git clone --single-branch --branch badges https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git . 2>/dev/null
cp -r ${{ github.workspace }}/badges .
git add badges
if git commit -m "Update badges [skip ci]"; then
git push origin badges --force
echo "Badges updated successfully"
else
echo "No changes to badges"
fi
if: ${{ always() }}
- name: Deploy docs
# run in the build workflow since schemagen has homeassistant dependency
run: |
sudo apt-get install pngquant
uv sync --group docs
git config push.autoSetupRemote true
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git fetch origin gh-pages
if [ "${{ github.event_name }}" = "release" ]; then
TAG="${{ github.event.release.tag_name }}"
if [[ "${{ github.event.release.prerelease }}" = "true" ]]; then
echo "Deploying prerelease version: $TAG"
uv run mike deploy --update-aliases "$TAG" beta
else
echo "Deploying stable release: $TAG"
uv run mike deploy --update-aliases "$TAG" latest
uv run mike set-default latest
fi
else
echo "Deploying development docs"
uv run mike deploy --update-aliases dev
fi
git push origin gh-pages --force-with-lease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}