-
-
Notifications
You must be signed in to change notification settings - Fork 21
98 lines (84 loc) · 2.96 KB
/
workflow.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
name: Build, release, push
permissions:
contents: write
on:
workflow_dispatch:
push:
tags:
- '*' # Push events to matching *, any
jobs:
build_release_push:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Install Node JS
uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install PlatformIO Core
run: pip install --upgrade platformio==6.1.11
- name: Build PlatformIO Project
run: pio run
- name: Get Release Version
id: get_version
shell: bash
run: |
value=$(grep '#define VERSION' src/version.h | awk -F '"' '{print $2}')
echo "version=$value" >> $GITHUB_OUTPUT
- name: Get last commit message
id: get_commit_message
run: |
commitMessage=$(git log -1 --pretty=%B | tail -n +3)
echo "commitMessage<<EOF" >> $GITHUB_ENV
echo "$commitMessage" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Calculate SHA-256 hash of the firmware
id: sha256_hash
run: |
echo "sha256=$(sha256sum bin/XZG_${{ steps.get_version.outputs.version }}.full.bin | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Get size of the firmware
id: firmware_size
run: |
echo "size=$(stat -c %s bin/XZG_${{ steps.get_version.outputs.version }}.full.bin)" >> $GITHUB_OUTPUT
- name: Create manifest.json for ESP Web Tools
run: |
cat << EOF > manifest.json
{
"name": "XZG Firmware",
"version": "${{ steps.get_version.outputs.version }}",
"files": [
{
"path": "XZG_${{ steps.get_version.outputs.version }}.full.bin",
"type": "app",
"lzma": false,
"address": "0x0",
"sha256": "${{ steps.sha256_hash.outputs.sha256 }}",
"size": ${{ steps.firmware_size.outputs.size }},
"url": "https://github.com/${{ github.repository }}/releases/download/${{ steps.get_version.outputs.version }}/XZG_${{ steps.get_version.outputs.version }}.full.bin"
}
],
"chipFamily": "ESP32"
}
EOF
echo "Manifest file created."
- name: Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: false
name: "${{ steps.get_version.outputs.version }}"
body: ${{ env.commitMessage }}
files: |
bin/XZG_${{ steps.get_version.outputs.version }}.ota.bin
bin/XZG_${{ steps.get_version.outputs.version }}.full.bin
manifest.json