Skip to content

Commit 77ac8e9

Browse files
committed
add GitHub Actions for build and release
1 parent e890b25 commit 77ac8e9

File tree

6 files changed

+176
-0
lines changed

6 files changed

+176
-0
lines changed

.github/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!actions/*
Lines changed: 43 additions & 0 deletions
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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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-binaries:
13+
runs-on: ubuntu-latest
14+
env:
15+
RELEASE_DIR: Release
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
submodules: true
21+
- name: Build
22+
uses: ./.github/actions/build-and-rename
23+
with:
24+
path: .
25+
build: build
26+
platform: rp2350
27+
board: pico2
28+
identifier: pico2
29+
output_path: ${{ env.RELEASE_DIR }}
30+
- name: Upload production artifacts
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: dist-binaries
34+
path: |
35+
${{ env.RELEASE_DIR }}/*.uf2
36+
${{ env.RELEASE_DIR }}/*.elf
37+
38+
release-tag-condition:
39+
runs-on: ubuntu-latest
40+
outputs:
41+
matched: ${{ steps.check.outputs.matched }}
42+
steps:
43+
- name: Check if Release Tag Condition Matched
44+
id: check
45+
run: |
46+
if [[ ${{ github.ref_type }} == 'tag' && ${{ github.ref_name }} =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
47+
echo "matched=true" >> $GITHUB_OUTPUT
48+
echo "Release tag condition matched"
49+
else
50+
echo "matched=false" >> $GITHUB_OUTPUT
51+
echo "Release tag condition not matched"
52+
fi
53+
54+
call-upload-release-asset:
55+
needs: [build-binaries, release-tag-condition]
56+
if: ${{ needs.release-tag-condition.outputs.matched == 'true' }}
57+
uses: ./.github/workflows/upload-release-asset.yml
58+
with:
59+
source_run_id: ${{ github.run_id }}
60+
artifacts_dirs: "dist-binaries"
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
artifacts_dirs:
17+
description: 'The directories of the artifacts'
18+
type: string
19+
required: true
20+
21+
jobs:
22+
upload-release-asset:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: write
26+
checks: write
27+
env:
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
CHANGELOG: ./CHANGELOG.md
30+
RELEAESE_NOTE: ./ReleaseNote.md
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- name: Extract Release Note from CHANGELOG
35+
run: |
36+
pattern1="^## \[${{ github.ref_name }}\]"
37+
pattern2="^## \["
38+
print=false
39+
while read line; do
40+
if [[ $line =~ $pattern1 ]]; then
41+
print=true
42+
elif [[ $line =~ $pattern2 ]]; then
43+
print=false
44+
elif $print; then
45+
echo "$line" >> ${{ env.RELEAESE_NOTE }}
46+
fi
47+
done < ${{ env.CHANGELOG }}
48+
- name: Create Release as Draft
49+
id: create-release
50+
run: |
51+
gh release create ${{ github.ref_name }} \
52+
--title "Release ${{ github.ref_name }}" \
53+
--notes-file ${{ env.RELEAESE_NOTE}} \
54+
--draft \
55+
--target ${{ github.sha }}
56+
- name: Download Artifacts
57+
id: download-artifacts
58+
run: |
59+
gh run download ${{ inputs.source_run_id }}
60+
- name: Upload Release Assets
61+
id: upload-release-assets
62+
run: |
63+
for dir in ${{ inputs.artifacts_dirs }}; do
64+
for file in $(ls $dir/*.uf2 $dir/*.elf); do
65+
gh release upload ${{ github.ref_name }} "$file"
66+
done
67+
done

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
8+
9+
## [1.0.2] - 2025-04-28
810
### Added
911
* Support FM64429 Electric Volume
12+
* Add GitHub Actions for build and release
1013
### Changed
1114
* Support pico-sdk 2.1.1
1215
* Change target from rp2040 (Raspberry Pi Pico) to rp2350 (Raspberry Pi Pico 2) for ADC mulfunction fix

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
![LevelMeterScene](doc/level_meter_scene01.jpg)
44

5+
[![Build](https://github.com/elehobica/pico_level_meter/actions/workflows/build-binaries.yml/badge.svg)](https://github.com/elehobica/pico_level_meter/actions/workflows/build-binaries.yml)
6+
57
## Overview
68
This is Audio Level Meter library for rp2350
79

0 commit comments

Comments
 (0)