Skip to content

Commit 4082a3f

Browse files
committed
ci: release single binaries .zip, merge all available build artifacts
1 parent d60b58d commit 4082a3f

File tree

4 files changed

+164
-100
lines changed

4 files changed

+164
-100
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
# Checks whether the pushed commit can be build with PIO. Only triggered on normal push to the mega branch without tag and with pull requests targeting mega
2+
13
name: Build
24

3-
on: [push, pull_request]
5+
on:
6+
push:
7+
branches: [mega]
8+
tags-ignore: '**'
9+
pull_request:
10+
branches: [mega]
411

512
jobs:
613
generate-matrix:
@@ -16,6 +23,7 @@ jobs:
1623
run: |
1724
pip install platformio
1825
python tools/ci/generate-matrix.py
26+
1927
build:
2028
needs: generate-matrix
2129
runs-on: ubuntu-20.04
@@ -57,61 +65,3 @@ jobs:
5765
name: Binaries
5866
path: ESPEasy_${{ matrix.env }}.zip
5967
if-no-files-found: ignore
60-
release-files:
61-
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
62-
runs-on: ubuntu-20.04
63-
outputs:
64-
message: ${{ steps.release-notes.outputs.message }}
65-
steps:
66-
- uses: actions/checkout@v2
67-
- uses: actions/setup-python@v2
68-
with:
69-
python-version: '3.8'
70-
- uses: actions/cache@v2
71-
with:
72-
path: ~/.cache/pip
73-
key: ${{ runner.os }}-docs-${{ hashFiles('requirements.txt') }}
74-
- name: Build documentation
75-
run: |
76-
cd docs
77-
sudo apt install imagemagick zip
78-
pip install -r requirements.txt
79-
make html
80-
cd ..
81-
zip -r -qq ESPEasy_docs.zip docs/build/*
82-
- name: Package utilities
83-
run: |
84-
cd dist
85-
zip -r -qq ../ESPEasy_dist.zip *
86-
cd ..
87-
- name: Extract release notes
88-
id: release-notes
89-
run: |
90-
git fetch --force origin ${GITHUB_REF}:${GITHUB_REF} # see https://github.com/actions/checkout/issues/290
91-
echo ::set-output name=message::$(git --no-pager tag -l --format="%(contents)" ${GITHUB_REF:10})
92-
- uses: actions/upload-artifact@v2
93-
with:
94-
path: |
95-
tools/ci/upload-release.py
96-
ESPEasy_docs.zip
97-
ESPEasy_dist.zip
98-
release:
99-
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
100-
runs-on: ubuntu-20.04
101-
needs: [release-files, build]
102-
steps:
103-
- uses: actions/setup-python@v2
104-
with:
105-
python-version: '3.8'
106-
- uses: actions/download-artifact@v2
107-
with:
108-
path: artifacts/
109-
- name: Create release
110-
working-directory: artifacts/
111-
env:
112-
RELEASE_NOTES: ${{ needs.release-files.outputs.message }}
113-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114-
run: |
115-
ls -R
116-
pip install PyGithub
117-
python3 artifact/tools/ci/upload-release.py

.github/workflows/release.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# TODO: consider updating requirements.txt for the documentation step,
2+
# as it does not work with python versions >3.8
3+
#
4+
# NOTICE the generate-matrix and build are c/p from the build workflow
5+
# NOTICE manual deletion following a re-created tag and push will also trigger this
6+
#
7+
# Checks whether the pushed commit is buildable and creates a release with the provided tag. Only triggered on mega-* tag push
8+
# Documentation and distribution files (tools, readme, etc.) are uploaded as .zip files prepared similarly to the build_ESPEasy.sh
9+
# Every .bin build artifact is merged in a single .zip file, which is then uploaded as a single release asset
10+
11+
name: Release
12+
13+
on:
14+
push:
15+
branches-ignore: '**'
16+
tags: 'mega-*'
17+
18+
jobs:
19+
generate-matrix:
20+
runs-on: ubuntu-20.04
21+
outputs:
22+
matrix: ${{ steps.set-matrix.outputs.matrix }}
23+
steps:
24+
- uses: actions/checkout@v2
25+
- uses: actions/setup-python@v2
26+
with:
27+
python-version: '3.8'
28+
- id: set-matrix
29+
run: |
30+
pip install platformio
31+
python tools/ci/generate-matrix.py
32+
33+
build:
34+
needs: generate-matrix
35+
runs-on: ubuntu-20.04
36+
strategy:
37+
matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
38+
steps:
39+
- uses: actions/checkout@v2
40+
- uses: actions/setup-python@v2
41+
with:
42+
python-version: '3.8'
43+
- uses: actions/cache@v2
44+
with:
45+
path: ~/.cache/pip
46+
key: ${{ runner.os }}-${{ hashFiles('requirements.txt') }}
47+
- uses: actions/cache@v2
48+
if: ${{ contains(matrix.env, 'esp32') }}
49+
with:
50+
path: ~/.platformio
51+
key: ${{ runner.os }}-esp32-${{ hashFiles('platformio*.ini') }}
52+
- uses: actions/cache@v2
53+
if: ${{ contains(matrix.env, 'esp8266') }}
54+
with:
55+
path: ~/.platformio
56+
key: ${{ runner.os }}-esp8266-${{ hashFiles('platformio*.ini') }}
57+
- name: Dependencies
58+
run: |
59+
sudo apt install binutils
60+
pip install -r requirements.txt
61+
platformio update
62+
- name: Build and archive
63+
id: build-and-archive
64+
env:
65+
CHIP: ${{ matrix.chip }}
66+
ENV: ${{ matrix.env }}
67+
run: |
68+
python tools/ci/build-and-archive.py
69+
- uses: actions/upload-artifact@v2
70+
with:
71+
name: Binaries
72+
path: ESPEasy_${{ matrix.env }}.zip
73+
if-no-files-found: ignore
74+
75+
prepare-dist:
76+
needs: build
77+
runs-on: ubuntu-20.04
78+
steps:
79+
- uses: actions/checkout@v2
80+
- uses: actions/setup-python@v2
81+
with:
82+
python-version: '3.8'
83+
- uses: actions/cache@v2
84+
with:
85+
path: ~/.cache/pip
86+
key: ${{ runner.os }}-docs-${{ hashFiles('requirements.txt') }}
87+
- name: Build documentation
88+
run: |
89+
cd docs
90+
sudo apt install imagemagick zip
91+
pip install -r requirements.txt
92+
make html
93+
cd ..
94+
zip -r -qq ESPEasy_docs.zip docs/build/*
95+
- name: Package utilities
96+
run: |
97+
cd dist
98+
zip -r -qq ../ESPEasy_dist.zip *
99+
cd ..
100+
- uses: actions/upload-artifact@v2
101+
with:
102+
name: Distribution
103+
path: |
104+
ESPEasy_docs.zip
105+
ESPEasy_dist.zip
106+
107+
prepare-notes:
108+
needs: build
109+
runs-on: ubuntu-20.04
110+
outputs:
111+
notes: ${{ steps.release-notes.outputs.result }}
112+
steps:
113+
- id: release-notes
114+
uses: actions/github-script@v4
115+
with:
116+
result-encoding: string
117+
script: |
118+
const tagRefObj = await github.git.getRef({
119+
...context.repo,
120+
ref: context.ref.replace('refs/', '')
121+
});
122+
123+
const tagObj = await github.git.getTag({
124+
...context.repo,
125+
tag_sha: tagRefObj.data.object.sha
126+
});
127+
128+
return tagObj.data.message;
129+
130+
release:
131+
needs: [build, prepare-dist, prepare-notes]
132+
runs-on: ubuntu-20.04
133+
steps:
134+
- uses: actions/setup-python@v2
135+
with:
136+
python-version: '3.8'
137+
- uses: actions/download-artifact@v2
138+
with:
139+
path: artifacts/
140+
- run: |
141+
ls -R
142+
sudo apt install zipmerge
143+
zipmerge ESPEasy_binaries.zip artifacts/Binaries/*.zip
144+
- uses: ncipollo/release-action@v1
145+
with:
146+
artifacts: "ESPEasy_binaries.zip,artifacts/Distribution/*.zip"
147+
body: ${{ needs.prepare-notes.outputs.notes }}
148+
token: ${{ secrets.GITHUB_TOKEN }}

tools/ci/generate-matrix.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
# ref. https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/
2+
#
3+
# This script is expected to print out something like this to supply the next Actions step with environments to build in parallel:
4+
# ::set-output name=matrix::{"include": [{"chip": "esp8266", "env": "custom_ESP8266_4M1M"}, {"chip": "esp32", "env": "custom_ESP32_4M316k"}]}
5+
#
6+
# These are the same environment names as with tools/build_ESPeasy.sh (i.e. all of them)
7+
18
import json
29
from platformio.project.config import ProjectConfig
310

4-
# This will select the same environments as tools/build_ESPeasy.sh
5-
611

712
def get_jobs(cfg):
813
for env in cfg.envs():
@@ -25,10 +30,6 @@ def filter_jobs(jobs, ignore=("spec_",)):
2530
yield job
2631

2732

28-
# ref. https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/
29-
# we need to echo something like this:
30-
# ::set-output name=matrix::{"include": [{"chip": "esp8266", "env": "custom_ESP8266_4M1M"}, {"chip": "esp32", "env": "custom_ESP32_4M316k"}]}
31-
3233
if __name__ == "__main__":
3334
jobs = list(filter_jobs(get_jobs(ProjectConfig.get_instance())))
3435

tools/ci/upload-release.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)