-
Notifications
You must be signed in to change notification settings - Fork 2
228 lines (200 loc) · 9.21 KB
/
BuildAndDeploy.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# https://github.com/marketplace/actions/test-compile-for-arduino
# https://github.com/marketplace/actions/test-compile-for-arduino#multiple-boards-with-parameter-using-the-script-directly
# https://github.com/actions/upload-release-asset/issues/17
# https://github.com/dh1tw/remoteAudio/blob/master/.github/workflows/build.yml
name: Build&Deploy
on:
push:
branches:
- master
- prelive
- development
jobs:
create_Release:
runs-on: ubuntu-latest
if: endsWith(github.ref, 'master') || endsWith(github.ref, 'prelive')
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: set Environment Variables
id: set_env_var
run: |
VERSION=$(sed 's/[^0-9|.]//g' _Release.h) # zb. 2.4.2
if [ ${{ github.ref }} == 'refs/heads/master' ]; then IS_PRE='false'; else IS_PRE='true'; fi
if [ ${{ github.ref }} == 'refs/heads/master' ]; then POSTFIX='' ; else POSTFIX='PRE'; fi
RELEASEBODY=$(awk -v RS='Release ' '/'$VERSION':(.*)/ {print $0}' ChangeLog.h)
RELEASEBODY="${RELEASEBODY//'%'/'%25'}"
RELEASEBODY="${RELEASEBODY//$'\n'/'%0A'}"
RELEASEBODY="${RELEASEBODY//$'\r'/'%0D'}"
echo "::set-output name=version::${VERSION}"
echo "::set-output name=IS_PRERELEASE::${IS_PRE}"
echo "::set-output name=RELEASENAME_POSTFIX::${POSTFIX}"
echo "::set-output name=RELEASEBODY::${RELEASEBODY}"
env:
REPOSITORY: ${{ github.event.repository.name }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: v.${{ steps.set_env_var.outputs.version }}-${{ steps.set_env_var.outputs.RELEASENAME_POSTFIX }}-${{ github.run_id }}
release_name: Release ${{ steps.set_env_var.outputs.version }} ${{ steps.set_env_var.outputs.RELEASENAME_POSTFIX }}
body: |
${{ steps.set_env_var.outputs.RELEASEBODY }}
draft: false
prerelease: ${{ steps.set_env_var.outputs.IS_PRERELEASE }}
- name: Copy release URL into file
run: |
mkdir release
printf "%s" "${{ steps.create_release.outputs.upload_url }}" > release/url.txt
- name: Stash file containing the release URL as an artifact
uses: actions/upload-artifact@v1
with:
name: release-url
path: ./release
build:
name: BuildAndDeploy-${{ matrix.arduino-boards-fqbn }}
runs-on: ubuntu-latest
env:
REQUIRED_LIBRARIES: WiFiManager,PubSubClient,ESP8266 and ESP32 OLED driver for SSD1306 displays,Uptime Library,OneWire,ADS1115_WE
REPOSITORY: ${{ github.event.repository.name }}
sketch-name: ESP8266_PumpControl.ino
#FULLREPO: ${{ github.repository }} # tobiasfaust/test
strategy:
matrix:
arduino-boards-fqbn:
- esp8266:esp8266:d1_mini
- esp32:esp32:esp32
include:
# - arduino-boards-fqbn: arduino:avr:uno
# #sketch-names: WhistleSwitch.ino,SimpleFrequencyDetector.ino # Comma separated list of sketch names (no path required) or patterns to use in build
- arduino-boards-fqbn: esp8266:esp8266:d1_mini
platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
architecture: ESP8266
save_libs: libraries_esp8266.zip # name must be unique, it makes sense to define it only once
- arduino-boards-fqbn: esp32:esp32:esp32
platform-url: https://dl.espressif.com/dl/package_esp32_index.json
# extra-arduino-cli-args: "--build-property build.partitions=no_ota --build-property upload.maximum_size=2097152"
architecture: ESP32
save_libs: libraries_esp32.zip # name must be unique, it makes sense to define it only once
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Checkout Wemos MotorDriver Library
uses: actions/checkout@v2
with:
repository: wemos/WEMOS_Motor_Shield_Arduino_Library
ref: master
path: WEMOS_Motor_Shield_Custom_Library
- name: Checkout I2CDetect Library
uses: actions/checkout@v2
with:
repository: tobiasfaust/i2cdetect
ref: master
path: i2cDetect_Custom_Library
- name: Checkout ESPHTTPUpdateServer
uses: actions/checkout@v2
with:
repository: tobiasfaust/ESPHTTPUpdateServer
ref: master
path: ESPHTTPUpdateServer_Custom_Library
- name: Checkout PCF8574_library
uses: actions/checkout@v2
with:
repository: xreef/PCF8574_library
ref: master
path: PCF8574_Custom_Library
- name: Checkout ArduinoJson library
uses: actions/checkout@v2
with:
repository: bblanchon/ArduinoJson
ref: 5.x
path: ArduinoJson_Custom_Library
- name: Checkout DS2408 library
uses: actions/checkout@v2
with:
repository: tobiasfaust/arduino-ds2408
ref: master
path: DS2408_Custom_Library
- name: Arduino build
uses: ArminJo/arduino-test-compile@v3
with:
arduino-board-fqbn: ${{ matrix.arduino-boards-fqbn }}
platform-url: ${{ matrix.platform-url }}
required-libraries: ${{ env.REQUIRED_LIBRARIES }}
sketch_names: ${{ env.sketch-name }}
extra-arduino-cli-args: ${{ matrix.extra-arduino-cli-args }}
- if: endsWith(github.ref, 'master')
name: Set Environment Variable "PRODUCTION"
run: echo "ENV_STAGE=PROD" >> $GITHUB_ENV
- if: endsWith(github.ref, 'prelive')
name: Set Environment Variable "PreLive"
run: echo "ENV_STAGE=PRE" >> $GITHUB_ENV
- if: endsWith(github.ref, 'development')
name: Set Environment Variable "Development"
run: echo "ENV_STAGE=DEV" >> $GITHUB_ENV
# Script um JSON Datei zu erstellen
- name: Schreibe Json File
env:
ENV_ARCH: ${{ matrix.architecture }}
ENV_REPOSITORYNAME: ${{ env.REPOSITORY }}
ENV_BINARYPATH: "${{ format('/home/runner/{0}/build', env.REPOSITORY) }}"
ENV_DESTPATH: "release"
ENV_SUBVERSION: ${{ github.run_number }}
ENV_RELEASEFILE: "${{ format('/home/runner/{0}/_Release.h', env.REPOSITORY) }}"
run: |
mkdir release
chmod +x .github/workflows/generateJSON.sh
.github/workflows/generateJSON.sh
- uses: jakejarvis/s3-sync-action@master
with:
args: '--acl public-read --follow-symlinks'
env:
AWS_S3_BUCKET: 'tfa-releases'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'eu-central-1' # optional: defaults to us-east-1
SOURCE_DIR: 'release' # optional: defaults to entire repository
DEST_DIR: ${{ env.REPOSITORY }}
# Download the previously uploaded artifact which contains the release URL
- name: Retrieve stashed release URL
if: endsWith(github.ref, 'master') || endsWith(github.ref, 'prelive')
uses: actions/download-artifact@v1
with:
name: release-url
- name: Read release URL
id: set_asset_env
if: endsWith(github.ref, 'master') || endsWith(github.ref, 'prelive')
run: |
echo "BOARD=${{ matrix.arduino-boards-fqbn }}" >> $GITHUB_ENV
echo ::set-output name=URL::$(cat release-url/url.txt)
echo ::set-output name=BinaryName::$(cat release/*$BOARD*.json | cut -d"\"" -f24 | cut -d "/" -f5)
echo ::set-output name=BinaryPath::release/$(cat release/*.json | cut -d"\"" -f24 | cut -d "/" -f5)
- name: Upload Release Asset
id: upload-release-asset
if: endsWith(github.ref, 'master') || endsWith(github.ref, 'prelive')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.set_asset_env.outputs.URL }}
asset_path: ${{ steps.set_asset_env.outputs.BinaryPath }}
asset_name: ${{ steps.set_asset_env.outputs.BinaryName }}
asset_content_type: application/x-binary
- name: collect and zip libraries
if: (endsWith(github.ref, 'master') || endsWith(github.ref, 'prelive')) && endsWith(matrix.save_libs, 'zip')
run: |
rsync -arv --exclude='*git*' --exclude='*examples*' --exclude='*resources*' /home/runner/Arduino/libraries/ ./libraries
zip -r ${{ matrix.save_libs }} libraries/*
- name: Upload Libraries to Release
id: upload-release-libs
if: (endsWith(github.ref, 'master') || endsWith(github.ref, 'prelive')) && endsWith(matrix.save_libs, 'zip')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.set_asset_env.outputs.URL }}
asset_path: ./${{ matrix.save_libs }}
asset_name: ${{ matrix.save_libs }}
asset_content_type: application/zip