Repository navigation
111 lines (94 loc) Β· 3.6 KB
/
Copy pathrelease.yml
File metadata and controls
111 lines (94 loc) Β· 3.6 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
name: π Validate and Release
on:
workflow_dispatch:
jobs:
validate-hassfest:
name: βοΈ Validate with hassfest
runs-on: "ubuntu-latest"
steps:
- name: Checkout code
uses: "actions/checkout@v4"
- name: Run hassfest validation
uses: "home-assistant/actions/hassfest@master"
validate-hacs:
name: βοΈ Validate with HACS
runs-on: "ubuntu-latest"
steps:
- name: Checkout code
uses: "actions/checkout@v4"
- name: Run HACS validation
uses: "hacs/action@main"
with:
category: "integration"
release:
name: β
Create Release
runs-on: ubuntu-latest
needs: [validate-hassfest, validate-hacs]
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/dev')
permissions:
contents: write # Required to create tags and releases
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to check for existing tags properly
- name: Install jq
run: sudo apt-get install -y jq
- name: Get version details
id: get_version
run: |
# Get version from manifest
VERSION=$(jq -r .version custom_components/hon/manifest.json)
TAG_NAME="v$VERSION"
# Set environment variables for subsequent steps
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "RELEASE_TITLE=v$VERSION" - π±π²π>> $GITHUB_ENV
- name: Check for existing tag
id: check_tag
run: |
# Check if tag exists remotely
if git ls-remote --exit-code --tags origin "refs/tags/${{ env.TAG_NAME }}" >/dev/null 2>&1; then
echo "Tag ${{ env.TAG_NAME }} already exists. Skipping release."
echo "SKIP=true" >> $GITHUB_ENV
else
echo "Tag ${{ env.TAG_NAME }} does not exist. Proceeding."
echo "SKIP=false" >> $GITHUB_ENV
fi
- name: Create and Push Tag
if: env.SKIP == 'false'
run: |
# Configure git user
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Create annotated tag
git tag -a "${{ env.TAG_NAME }}" -m "${{ env.RELEASE_TITLE }}"
# Push the tag
git push origin "${{ env.TAG_NAME }}"
- name: Create Release Body
if: env.SKIP == 'false'
run: |
# Create markdown file for release notes
cat << EOF > release_body.md
# π βΊβΊ *${{ env.VERSION }}* - π±π²π released! β’ πΏ
<img height="128" alt="image" src="https://raw.githubusercontent.com/Bitte-ein-Git/ha_hon/dev/img/hOn.png" />
EOF
- name: ZIP Component Dir
if: env.SKIP == 'false'
run: |
# Navigate to component directory
cd ${{ github.workspace }}/custom_components/hon
# Create zip archive
zip -r haier_hon.zip ./
# Move zip to workspace root
mv haier_hon.zip ${{ github.workspace }}/haier_hon.zip
- name: Create Release
if: env.SKIP == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create GitHub release using the pushed tag
gh release create ${{ env.TAG_NAME }} \
--title "${{ env.RELEASE_TITLE }}" \
--notes-file release_body.md \
${{ github.workspace }}/haier_hon.zip#haier_hon.zip