-
Notifications
You must be signed in to change notification settings - Fork 16
171 lines (167 loc) · 11.9 KB
/
release.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
# get_default_envs:
# name: Gather Environments
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-python@v2
# - name: Install PlatformIO
# run: |
# pip install -U platformio
# platformio update
# - name: Dump github context
# run: echo "$GITHUB_CONTEXT"
# shell: bash
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# - name: Get default environments
# id: envs
# run: |
# echo "::set-output name=environments::$(pio project config --json-output | jq -cr '.[0][1][0][1]')"
# echo ${{ steps.envs.outputs.environments }}
# outputs:
# environments: ${{ steps.envs.outputs.environments }}
build:
name: Create Release
runs-on: ubuntu-latest
# needs: get_default_envs
strategy:
matrix:
# environment: ${{ fromJSON(needs.get_default_envs.outputs.environments) }}
environment: [TTGO_TDISPLAY, TTGO_TDISPLAY_SANDWICH]
# environment: [esp32dev, esp32dev-sandwich]
# environment: [esp32dev-sandwich]
steps:
- name: Checkout code
uses: actions/checkout@v2
- 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 -U platformio
platformio update
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- name: Show version
run: echo ${{ steps.get_version.outputs.VERSION }}
- name: Get current date
id: date
run: |
echo "::set-output name=date::$(date +'%d-%m-%Y')"
echo "::set-output name=time::$(date +'%H:%M:%S')"
- name: Build test version
run: |
# pio run -e ${{ matrix.environment }}
pio run -e ${{ matrix.environment }} -t upload buildfs
- name: Create manifest file
id: createmanifest
run: |
# Create "normal" (no memory erase manifest)
echo "{" > ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " \"name\": \"${{ github.event.repository.name }}-${{ matrix.environment }}\"," >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " \"version\": \"${{ steps.get_version.outputs.VERSION }}\"," >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " \"compilation_date\": \"${{ steps.date.outputs.date }}\"," >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " \"compilation_time\": \"${{ steps.date.outputs.time }}\"," >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " \"new_install_skip_erase\": true," >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " \"builds\": [" >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " {" >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " \"chipFamily\": \"ESP32\"," >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " \"improv\": false," >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " \"parts\": [" >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " { \"path\": \"bootloader_dio_40m.bin\", \"offset\": 4096 }," >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " { \"path\": \"partitions.bin\", \"offset\": 32768 }," >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " { \"path\": \"boot_app0.bin\", \"offset\": 57344 }," >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " { \"path\": \"${{ github.event.repository.name }}-${{ matrix.environment }}-${{ steps.get_version.outputs.VERSION }}.bin\", \"offset\": 65536 }" >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " { \"path\": \"spiffs-${{ github.event.repository.name }}-${{ matrix.environment }}-${{ steps.get_version.outputs.VERSION }}.bin\", \"offset\": 3997696 }" >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " ]" >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " }" >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo " ]" >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo "}" >> ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo "::set-output name=manifest::$(cat ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json)"
#
# Create "erase" (memory erase manifest)
echo "{" > ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " \"name\": \"${{ github.event.repository.name }}-${{ matrix.environment }}\"," >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " \"version\": \"${{ steps.get_version.outputs.VERSION }}\"," >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " \"compilation_date\": \"${{ steps.date.outputs.date }}\"," >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " \"compilation_time\": \"${{ steps.date.outputs.time }}\"," >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " \"new_install_skip_erase\": false," >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " \"builds\": [" >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " {" >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " \"chipFamily\": \"ESP32\"," >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " \"improv\": false," >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " \"parts\": [" >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " { \"path\": \"bootloader_dio_40m.bin\", \"offset\": 4096 }," >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " { \"path\": \"partitions.bin\", \"offset\": 32768 }," >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " { \"path\": \"boot_app0.bin\", \"offset\": 57344 }," >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " { \"path\": \"${{ github.event.repository.name }}-${{ matrix.environment }}-${{ steps.get_version.outputs.VERSION }}.bin\", \"offset\": 65536 }" >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " { \"path\": \"spiffs-${{ github.event.repository.name }}-${{ matrix.environment }}-${{ steps.get_version.outputs.VERSION }}.bin\", \"offset\": 3997696 }" >> ${{ github.event.repository.name }}-${{ matrix.environment }}.erase.manifest.json
echo " ]" >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " }" >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo " ]" >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo "}" >> ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
echo "::set-output name=erase-manifest::$(cat ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json)"
- name: Read manifest files with cat
run: |
echo "Manifest file contents readed with cat:"
cat ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
echo "Erase manifest file contents readed with cat:"
cat ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
- name: Read manifest files
id: readmanifests
run: |
echo "Manifest file contents from variable:"
echo ${{ steps.createmanifest.outputs.manifest }}
echo "Erase manifest file contents from variable:"
echo ${{ steps.createmanifest.outputs-erase.manifest }}
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ github.event.repository.name }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.environment }}
path: .pio/build/${{ matrix.environment }}/*.bin
- name: Rename bin file
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir .pio/build/${{ matrix.environment }}/output/
mv .pio/build/${{ matrix.environment }}/firmware.bin .pio/build/${{ matrix.environment }}/output/${{ github.event.repository.name }}-${{ matrix.environment }}-${{ steps.get_version.outputs.VERSION }}.bin
mv .pio/build/${{ matrix.environment }}/spiffs.bin .pio/build/spiffs-${{ matrix.environment }}/output/${{ github.event.repository.name }}-${{ matrix.environment }}-${{ steps.get_version.outputs.VERSION }}.bin
mv .pio/build/${{ matrix.environment }}/partitions.bin .pio/build/partitions-${{ matrix.environment }}/output/${{ github.event.repository.name }}-${{ matrix.environment }}-${{ steps.get_version.outputs.VERSION }}.bin
mv ${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json .pio/build/${{ matrix.environment }}/output/${{ github.event.repository.name }}-${{ matrix.environment }}.manifest.json
mv ${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json .pio/build/${{ matrix.environment }}/output/${{ github.event.repository.name }}-${{ matrix.environment }}-erase.manifest.json
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: ${{ github.event.repository.name }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.environment }}
files: |
.pio/build/${{ matrix.environment }}/output/*.bin
.pio/build/${{ matrix.environment }}/output/*.json
draft: true
# prerelease: true
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_ACTION_TOKEN }}
- name: 📂 Sync files - FTP-Deploy-Action
uses: SamKirkland/[email protected]
env:
FTP_SERVER: ${{ secrets.FTP_SERVER }}
FTP_USERNAME: ${{ secrets.FTP_USER }}
FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }}
LOCAL_DIR: .pio/build/${{ matrix.environment }}/output/
REMOTE_DIR: /public_html/wp-content/uploads/firmware/${{ github.event.repository.name }}/
METHOD: sftp
PORT: 22
ARGS: --verbose
- name: Clean WP Rocket Cache
run: curl https://emariete.com/clean_cache.php