Skip to content

Commit 78d370a

Browse files
committed
Automate release
1 parent dd29db9 commit 78d370a

File tree

2 files changed

+124
-42
lines changed

2 files changed

+124
-42
lines changed

.github/workflows/main-builder.yml

+70-42
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,76 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
workflow_call:
89

910
jobs:
1011
build:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: Download project files
14-
uses: actions/checkout@v3
15-
16-
- name: Cache XC-16 Compiler
17-
id: cache-compiler
18-
uses: actions/cache@v3
19-
with:
20-
path: ~/.cache/mplab-xc
21-
key: xc16-v2.10-cache
22-
23-
- name: Download XC16 Compiler
24-
if: steps.cache-compiler.outputs.cache-hit != 'true'
25-
run: |
26-
mkdir -p ~/.cache/mplab-xc
27-
cd ~/.cache/mplab-xc
28-
wget https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/SoftwareTools/xc16-v2.10-full-install-linux64-installer.run
29-
chmod +x xc16-v2.10-full-install-linux64-installer.run
30-
31-
- name: Install XC16 Compiler
32-
run: |
33-
cd ~/.cache/mplab-xc
34-
sudo ./xc16-v2.10-full-install-linux64-installer.run --mode unattended --netservername dontknow
35-
36-
- name: Set up cmake-microchip submodules
37-
run: |
38-
git submodule init
39-
git submodule update
40-
41-
- name: Build firmware
42-
run: |
43-
mkdir build
44-
cd build
45-
cmake ..
46-
make
47-
48-
- name: Publish build files
49-
uses: actions/upload-artifact@v4
50-
with:
51-
name: production-file
52-
path: build/*.hex
12+
strategy:
13+
matrix:
14+
build_type: [v6, v5, v6_esp01]
15+
include:
16+
- build_type: v6
17+
branch: main
18+
cmake_flags: '-DCMAKE_BUILD_TYPE=RelWithDebInfo'
19+
- build_type: v5
20+
branch: main
21+
cmake_flags: '-DCMAKE_BUILD_TYPE=RelWithDebInfo -DLEGACY_HARDWARE=1'
22+
- build_type: v6_esp01
23+
branch: esp-01
24+
cmake_flags: '-DCMAKE_BUILD_TYPE=RelWithDebInfo'
25+
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Download project files
29+
uses: actions/checkout@v4
30+
with:
31+
path: main
32+
33+
- name: Checkout ESP01 branch
34+
uses: actions/checkout@v4
35+
with:
36+
ref: esp-01
37+
path: esp-01
38+
39+
- name: Cache XC-16 Compiler
40+
id: cache-compiler
41+
uses: actions/cache@v3
42+
with:
43+
path: ~/.cache/mplab-xc
44+
key: xc16-v2.10-cache
45+
46+
- name: Download XC16 Compiler
47+
if: steps.cache-compiler.outputs.cache-hit != 'true'
48+
run: |
49+
mkdir -p ~/.cache/mplab-xc
50+
cd ~/.cache/mplab-xc
51+
wget https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/SoftwareTools/xc16-v2.10-full-install-linux64-installer.run
52+
chmod +x xc16-v2.10-full-install-linux64-installer.run
53+
54+
- name: Install XC16 Compiler
55+
run: |
56+
cd ~/.cache/mplab-xc
57+
sudo ./xc16-v2.10-full-install-linux64-installer.run --mode unattended --netservername dontknow
58+
59+
- name: Set up cmake-microchip submodules
60+
run: |
61+
cd main
62+
git submodule init
63+
git submodule update
64+
cd ../esp-01
65+
git submodule init
66+
git submodule update
67+
68+
- name: Build firmware
69+
run: |
70+
cd ${{ matrix.branch }}
71+
mkdir build_${{ matrix.build_type }}
72+
cd build_${{ matrix.build_type }}
73+
cmake .. ${{ matrix.cmake_flags}}
74+
make
75+
76+
- name: Publish build files
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: pslab-firmware_${{ matrix.build_type}}
80+
path: ${{ matrix.branch }}/build_${{ matrix.build_type }}/pslab-firmware.hex

.github/workflows/release.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
set-body:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- run: sudo apt install pcregrep
14+
15+
- uses: actions/checkout@v4
16+
17+
- name: Parse changelog
18+
id: parse-changelog
19+
run: |
20+
tag='${{ github.ref_name }}'
21+
re_current_tag="## \[$tag\].*\n\n" # Match, but do not capture, current version tag, then...
22+
re_changes_body='((.|\n)+?)' # capture everything including newlines...
23+
re_previous_tag='## \[[0-9]+.[0-9]+.[0-9]+\]' # until previous version tag.
24+
re_full="${re_current_tag}${re_changes_body}${re_previous_tag}"
25+
echo 'match<<EOF' >> $GITHUB_OUTPUT
26+
# Match multiple lines, output capture group 1.
27+
pcregrep -M -o1 "$re_full" ./CHANGELOG.md >> $GITHUB_OUTPUT
28+
echo 'EOF' >> $GITHUB_OUTPUT
29+
30+
- name: Set release body
31+
uses: softprops/action-gh-release@v2
32+
with:
33+
draft: true
34+
body: ${{ steps.parse-changelog.outputs.match }}
35+
36+
build:
37+
uses: fossasia/pslab-firmware/.github/workflows/main-builder.yml@main
38+
39+
attach-artifacts:
40+
needs: build
41+
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- name: download
46+
uses: actions/download-artifact@v4
47+
48+
- name: attach
49+
uses: softprops/action-gh-release@v2
50+
with:
51+
files: |
52+
pslab-firmware_v6.zip
53+
pslab-firmware_v5.zip
54+
pslab-firmware_v6_esp01.zip

0 commit comments

Comments
 (0)