Skip to content

Commit a300a99

Browse files
authored
add GitHub Actions for build and release (#20)
* add build-binaries workflow * add upload-release-asset workflow
1 parent 48c4cc5 commit a300a99

File tree

5 files changed

+214
-0
lines changed

5 files changed

+214
-0
lines changed

.github/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
!actions/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#------------------------------------------------------
2+
# Copyright (c) 2025, Elehobica
3+
# Released under the BSD-2-Clause
4+
# refer to https://opensource.org/licenses/BSD-2-Clause
5+
#------------------------------------------------------
6+
7+
name: Build and Rename
8+
9+
inputs:
10+
path:
11+
required: true
12+
build:
13+
required: false
14+
default: build
15+
platform:
16+
required: false
17+
default: rp2040
18+
board:
19+
required: false
20+
default: pico
21+
identifier:
22+
required: true
23+
output_path:
24+
required: false
25+
default: Release
26+
27+
runs:
28+
using: 'composite'
29+
steps:
30+
- name: Build
31+
uses: elehobica/build-pico@v1
32+
with:
33+
path: ${{ inputs.path }}
34+
build: ${{ inputs.build }}
35+
platform: ${{ inputs.platform }}
36+
board: ${{ inputs.board }}
37+
- name: Move artifacts
38+
uses: elehobica/add-identifier@v1
39+
with:
40+
paths: ${{ inputs.path }}/${{ inputs.build }}
41+
exts: .uf2 .elf
42+
identifier: ${{ inputs.identifier }}
43+
output_path: ${{ inputs.output_path }}

.github/workflows/build-binaries.yml

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#------------------------------------------------------
2+
# Copyright (c) 2025, Elehobica
3+
# Released under the BSD-2-Clause
4+
# refer to https://opensource.org/licenses/BSD-2-Clause
5+
#------------------------------------------------------
6+
7+
name: Build
8+
9+
on: [push, pull_request]
10+
11+
jobs:
12+
build-detect-samp-freq:
13+
runs-on: ubuntu-latest
14+
env:
15+
RELEASE_DIR: Release
16+
outputs:
17+
release-tag-condition-matched: ${{ steps.release-tag-condition.outputs.matched }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Build Pico
22+
uses: ./.github/actions/build-and-rename
23+
with:
24+
path: samples/detect_samp_freq
25+
build: build
26+
identifier: pico
27+
output_path: ${{ env.RELEASE_DIR }}
28+
- name: Build Pico 2
29+
uses: ./.github/actions/build-and-rename
30+
with:
31+
path: samples/detect_samp_freq
32+
build: build2
33+
platform: rp2350
34+
board: pico2
35+
identifier: pico2
36+
output_path: ${{ env.RELEASE_DIR }}
37+
- name: Upload production artifacts
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: dist-binaries0
41+
path: |
42+
${{ env.RELEASE_DIR }}/*.uf2
43+
${{ env.RELEASE_DIR }}/*.elf
44+
45+
build-spdif-to-i2s-32b:
46+
runs-on: ubuntu-latest
47+
env:
48+
RELEASE_DIR: Release
49+
outputs:
50+
release-tag-condition-matched: ${{ steps.release-tag-condition.outputs.matched }}
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
- name: Build Pico
55+
uses: ./.github/actions/build-and-rename
56+
with:
57+
path: samples/spdif_to_i2s_32b
58+
build: build
59+
identifier: pico
60+
output_path: ${{ env.RELEASE_DIR }}
61+
- name: Build Pico 2
62+
uses: ./.github/actions/build-and-rename
63+
with:
64+
path: samples/spdif_to_i2s_32b
65+
build: build2
66+
platform: rp2350
67+
board: pico2
68+
identifier: pico2
69+
output_path: ${{ env.RELEASE_DIR }}
70+
- name: Upload production artifacts
71+
uses: actions/upload-artifact@v4
72+
with:
73+
name: dist-binaries1
74+
path: |
75+
${{ env.RELEASE_DIR }}/*.uf2
76+
${{ env.RELEASE_DIR }}/*.elf
77+
78+
release-tag-condition:
79+
runs-on: ubuntu-latest
80+
outputs:
81+
matched: ${{ steps.check.outputs.matched }}
82+
steps:
83+
- name: Check if Release Tag Condition Matched
84+
id: check
85+
run: |
86+
if [[ ${{ github.ref_type }} == 'tag' && ${{ github.ref_name }} =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]]; then
87+
echo "matched=true" >> $GITHUB_OUTPUT
88+
echo "Release tag condition matched"
89+
else
90+
echo "matched=false" >> $GITHUB_OUTPUT
91+
echo "Release tag condition not matched"
92+
fi
93+
94+
call-upload-release-asset:
95+
needs: [build-detect-samp-freq, build-spdif-to-i2s-32b, release-tag-condition]
96+
if: ${{ needs.release-tag-condition.outputs.matched == 'true' }}
97+
uses: ./.github/workflows/upload-release-asset.yml
98+
with:
99+
source_run_id: ${{ github.run_id }}
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#------------------------------------------------------
2+
# Copyright (c) 2025, Elehobica
3+
# Released under the BSD-2-Clause
4+
# refer to https://opensource.org/licenses/BSD-2-Clause
5+
#------------------------------------------------------
6+
7+
name: Upload Release Asset
8+
9+
on:
10+
workflow_call:
11+
inputs:
12+
source_run_id:
13+
description: 'The run ID of the source workflow'
14+
type: string
15+
required: true
16+
17+
jobs:
18+
upload-release-asset:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
checks: write
23+
env:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
CHANGELOG: ./CHANGELOG.md
26+
RELEAESE_NOTE: ./ReleaseNote.md
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
- name: Extract Release Note from CHANGELOG
31+
run: |
32+
pattern1="^## \[${{ github.ref_name }}\]"
33+
pattern2="^## \["
34+
print=false
35+
while read line; do
36+
if [[ $line =~ $pattern1 ]]; then
37+
print=true
38+
elif [[ $line =~ $pattern2 ]]; then
39+
print=false
40+
elif $print; then
41+
echo "$line" >> ${{ env.RELEAESE_NOTE }}
42+
fi
43+
done < ${{ env.CHANGELOG }}
44+
- name: Create Release as Draft
45+
id: create-release
46+
run: |
47+
gh release create ${{ github.ref_name }} \
48+
--title "Release ${{ github.ref_name }}" \
49+
--notes-file ${{ env.RELEAESE_NOTE}} \
50+
--draft \
51+
--target ${{ github.sha }}
52+
- name: Download Artifacts 0
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: dist-binaries0
56+
github-token: ${{ env.GH_TOKEN }}
57+
run-id: ${{ inputs.source_run_id }}
58+
- name: Download Artifacts 1
59+
uses: actions/download-artifact@v4
60+
with:
61+
name: dist-binaries1
62+
github-token: ${{ env.GH_TOKEN }}
63+
run-id: ${{ inputs.source_run_id }}
64+
- name: Upload Release Asset
65+
id: upload-release-asset
66+
run: |
67+
for file in $(ls *.uf2 *.elf); do
68+
gh release upload ${{ github.ref_name }} "$file"
69+
done

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
* Support pico-sdk 2.1.1
1111
### Added
1212
* Support Raspberry Pi Pico 2 series board (up to 96.0 KHz)
13+
* Add GitHub Actions for build and release
1314

1415
## [v0.9.2] - 2023-04-05
1516
### Changed

0 commit comments

Comments
 (0)