1+ name : Publish Release
2+
3+ on :
4+ push :
5+ tags :
6+ - ' *'
7+
8+ jobs :
9+ build :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - uses : actions/checkout@v3
14+ with :
15+ fetch-depth : 0
16+ - run : git fetch --tags --force origin
17+ - uses : actions/cache@v3
18+ with :
19+ path : |
20+ ~/.cache/pip
21+ ~/.platformio/.cache
22+ .pio/build
23+ key : ${{ runner.os }}-pio
24+ - uses : actions/setup-python@v4
25+ with :
26+ python-version : ' 3.9'
27+
28+ - name : Validate docs
29+ run : |
30+ npm install -g redoc-cli
31+ redoc-cli validate ./docs/openapi.yaml
32+
33+ - name : Install PlatformIO Core
34+ run : pip install --upgrade platformio
35+
36+ - name : Build PlatformIO Project
37+ run : pio run
38+
39+ - name : Prepare release
40+ run : |
41+ ./.prepare_release
42+ ./.prepare_docs
43+
44+ - name : Upload production artifact
45+ uses : actions/upload-artifact@master
46+ with :
47+ name : dist
48+ path : dist
49+
50+ release :
51+ needs : build
52+ runs-on : ubuntu-latest
53+
54+ steps :
55+ - name : Download production artifact
56+ uses : actions/download-artifact@master
57+ with :
58+ name : dist
59+ path : dist
60+
61+ - name : Create Release
62+ uses : actions/github-script@v2
63+ with :
64+ github-token : ${{secrets.GITHUB_TOKEN}}
65+ script : |
66+ console.log('environment', process.versions);
67+
68+ const fs = require('fs').promises;
69+
70+ const { repo: { owner, repo }, sha } = context;
71+ console.log({ owner, repo, sha });
72+
73+ const release = await github.repos.createRelease({
74+ owner, repo,
75+ name: process.env.GITHUB_REF_NAME,
76+ body: await fs.readFile('./dist/release-notes.txt', 'utf8'),
77+ tag_name: process.env.GITHUB_REF,
78+ draft: true,
79+ target_commitish: sha
80+ });
81+
82+ console.log('created release', { release });
83+
84+ for (let file of await fs.readdir('dist')) {
85+ if (file.endsWith('.bin')) {
86+ console.log('uploading', file);
87+
88+ await github.repos.uploadReleaseAsset({
89+ owner, repo,
90+ release_id : release.data.id,
91+ name : file,
92+ data : await fs.readFile(`./dist/${file}`)
93+ });
94+ }
95+ }
96+
97+ publish_docs :
98+ needs : build
99+ runs-on : ubuntu-latest
100+
101+ # Deploy to the github-pages environment
102+ environment :
103+ name : github-pages
104+ url : ${{ steps.deployment.outputs.page_url }}
105+
106+ permissions :
107+ contents : write
108+
109+ steps :
110+ - uses : actions/checkout@v3
111+
112+ - name : Download production artifact
113+ uses : actions/download-artifact@master
114+ with :
115+ name : dist
116+ path : dist
117+
118+ - name : Release docs
119+ uses : JamesIves/github-pages-deploy-action@v4
120+ with :
121+ folder : dist/docs # The folder the action should deploy.
0 commit comments