-
-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathaction.yml
More file actions
118 lines (104 loc) · 4.28 KB
/
action.yml
File metadata and controls
118 lines (104 loc) · 4.28 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
111
112
113
114
115
116
117
118
name: 'Home Assistant helper: version'
description: 'GitHub action helper: version'
inputs:
type:
description: The type of target to check against (core, supervisor, plugin, generic)
required: false
default: 'generic'
outputs:
version:
description: The version found for the requested type
value: ${{ steps.version.outputs.version }}
stable:
description: Returns "true" if it is a stable build, else "false"
value: ${{ steps.version.outputs.stable }}
channel:
description: Returns suggested channel.
value: ${{ steps.channel.outputs.channel }}
publish:
description: Returns "true" if it should be published, else "false"
value: ${{ steps.publish.outputs.publish }}
runs:
using: "composite"
steps:
- shell: bash
run: |
if [[ -z "${{ inputs.type }}" ]];then
echo "::error::Missing required key 'type' input!"
exit 1
fi
- shell: bash
id: version
run: |
version=$(echo "${{ github.ref }}" | awk -F"/" '{print $NF}' )
if [[ ! -z "${{ github.event.inputs.version }}" ]]; then
version="${{ github.event.inputs.version }}"
elif [[ "${version}" =~ (master|main) && "${{ inputs.type }}" =~ (supervisor|plugin|generic) ]]; then
today="$(date --utc '+%Y-%m-%d')"
midnight_timestamp="$(date --utc +%s --date=$today)"
calver_date="$(date --utc --date=$today '+%Y.%m.dev%d')"
commit_count="$(git rev-list --count --since=$midnight_timestamp HEAD)"
commit_count="$(printf "%02d" ${commit_count})"
version="${calver_date}${commit_count}"
elif [[ "${version}" == "merge" && "${{ inputs.type }}" =~ (supervisor|plugin|generic) ]]; then
version="${{ github.sha }}"
elif [[ "${version}" == "dev" && "${{ inputs.type }}" == "core" ]]; then
python3 -m pip install packaging tomli
python3 -m pip install .
python3 script/version_bump.py nightly
version="$(python3 ${{ github.action_path }}/../read_version.py)"
fi
if [[ ! -z "${{ github.event.inputs.stable }}" ]]; then
stable="${{ github.event.inputs.stable }}"
elif [[ "${{ github.event_name }}" == "release" ]]; then
stable="true"
else
stable="false"
fi
echo "stable=$stable" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"
- shell: bash
run: |
if [[ "${{ inputs.type }}" == "supervisor" ]]; then
sed -i "s/^SUPERVISOR_VERSION =.*/SUPERVISOR_VERSION = \"${{ steps.version.outputs.version }}\"/g" supervisor/const.py
fi
- shell: bash
id: channel
run: |
if [[ ! -z "${{ github.event.inputs.channel }}" ]]; then
echo "channel=${{ github.event.inputs.channel }}" >> "$GITHUB_OUTPUT"
elif [[ "${{ inputs.type }}" =~ (plugin|supervisor) ]]; then
if [[ "${{ steps.version.outputs.stable }}" == "true" ]]; then
echo "channel=beta" >> "$GITHUB_OUTPUT"
else
echo "channel=dev" >> "$GITHUB_OUTPUT"
fi
elif [[ "${{ inputs.type }}" == "core" ]]; then
if [[ "${{ steps.version.outputs.version }}" =~ dev ]]; then
echo "channel=dev" >> "$GITHUB_OUTPUT"
elif [[ "${{ steps.version.outputs.version }}" =~ b ]]; then
echo "channel=beta" >> "$GITHUB_OUTPUT"
else
echo "channel=stable" >> "$GITHUB_OUTPUT"
fi
fi
- shell: bash
id: publish
run: |
if [[ ! -z "${{ github.event.inputs.publish }}" ]]; then
echo "publish=${{ github.event.inputs.publish }}" >> "$GITHUB_OUTPUT"
elif [[ "${{ inputs.type }}" =~ (plugin|supervisor) ]]; then
if [[ ! -z "${{ github.head_ref }}" ]]; then
echo "publish=false" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.event_name }}" =~ (release|push) ]]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
else
echo "publish=false" >> "$GITHUB_OUTPUT"
fi
elif [[ "${{ inputs.type }}" == "core" ]]; then
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
else
echo "publish=false" >> "$GITHUB_OUTPUT"
fi
fi