Skip to content

add github workflows and action #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
!actions/*
43 changes: 43 additions & 0 deletions .github/actions/build-and-rename/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#------------------------------------------------------
# Copyright (c) 2025, Elehobica
# Released under the BSD-2-Clause
# refer to https://opensource.org/licenses/BSD-2-Clause
#------------------------------------------------------

name: Build and Rename

inputs:
path:
required: true
build:
required: false
default: build
platform:
required: false
default: rp2040
board:
required: false
default: pico
identifier:
required: true
output_path:
required: false
default: Release

runs:
using: 'composite'
steps:
- name: Build
uses: elehobica/build-pico@v1
with:
path: ${{ inputs.path }}
build: ${{ inputs.build }}
platform: ${{ inputs.platform }}
board: ${{ inputs.board }}
- name: Move artifacts
uses: elehobica/add-identifier@v1
with:
paths: ${{ inputs.path }}/${{ inputs.build }}
exts: .uf2 .elf
identifier: ${{ inputs.identifier }}
output_path: ${{ inputs.output_path }}
68 changes: 68 additions & 0 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#------------------------------------------------------
# Copyright (c) 2025, Elehobica
# Released under the BSD-2-Clause
# refer to https://opensource.org/licenses/BSD-2-Clause
#------------------------------------------------------

name: Build

on: [push, pull_request]

jobs:
build-sine-wave-i2s_32b:
runs-on: ubuntu-latest
env:
PROJECT_DIR: samples/sine_wave_i2s_32b
RELEASE_DIR: Release
outputs:
release-tag-condition-matched: ${{ steps.release-tag-condition.outputs.matched }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Pico
uses: ./.github/actions/build-and-rename
with:
path: ${{ env.PROJECT_DIR }}
build: build
identifier: pico
output_path: ${{ env.RELEASE_DIR }}
- name: Build Pico 2
uses: ./.github/actions/build-and-rename
with:
path: ${{ env.PROJECT_DIR }}
build: build2
platform: rp2350
board: pico2
identifier: pico2
output_path: ${{ env.RELEASE_DIR }}
- name: Upload production artifacts
uses: actions/upload-artifact@v4
with:
name: dist-binaries0
path: |
${{ env.RELEASE_DIR }}/*.uf2
${{ env.RELEASE_DIR }}/*.elf

release-tag-condition:
runs-on: ubuntu-latest
outputs:
matched: ${{ steps.check.outputs.matched }}
steps:
- name: Check if Release Tag Condition Matched
id: check
run: |
if [[ ${{ github.ref_type }} == 'tag' && ${{ github.ref_name }} =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
echo "matched=true" >> $GITHUB_OUTPUT
echo "Release tag condition matched"
else
echo "matched=false" >> $GITHUB_OUTPUT
echo "Release tag condition not matched"
fi

call-upload-release-asset:
needs: [build-sine-wave-i2s_32b, release-tag-condition]
if: ${{ needs.release-tag-condition.outputs.matched == 'true' }}
uses: ./.github/workflows/upload-release-asset.yml
with:
source_run_id: ${{ github.run_id }}
artifacts_dirs: "dist-binaries0"
67 changes: 67 additions & 0 deletions .github/workflows/upload-release-asset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#------------------------------------------------------
# Copyright (c) 2025, Elehobica
# Released under the BSD-2-Clause
# refer to https://opensource.org/licenses/BSD-2-Clause
#------------------------------------------------------

name: Upload Release Asset

on:
workflow_call:
inputs:
source_run_id:
description: 'The run ID of the source workflow'
type: string
required: true
artifacts_dirs:
description: 'The directories of the artifacts'
type: string
required: true

jobs:
upload-release-asset:
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHANGELOG: ./CHANGELOG.md
RELEAESE_NOTE: ./ReleaseNote.md
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract Release Note from CHANGELOG
run: |
pattern1="^## \[${{ github.ref_name }}\]"
pattern2="^## \["
print=false
while read line; do
if [[ $line =~ $pattern1 ]]; then
print=true
elif [[ $line =~ $pattern2 ]]; then
print=false
elif $print; then
echo "$line" >> ${{ env.RELEAESE_NOTE }}
fi
done < ${{ env.CHANGELOG }}
- name: Create Release as Draft
id: create-release
run: |
gh release create ${{ github.ref_name }} \
--title "Release ${{ github.ref_name }}" \
--notes-file ${{ env.RELEAESE_NOTE}} \
--draft \
--target ${{ github.sha }}
- name: Download Artifacts
id: download-artifacts
run: |
gh run download ${{ inputs.source_run_id }}
- name: Upload Release Assets
id: upload-release-assets
run: |
for dir in ${{ inputs.artifacts_dirs }}; do
for file in $(ls $dir/*.uf2 $dir/*.elf); do
gh release upload ${{ github.ref_name }} "$file"
done
done
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
* Confirm with pico-sdk 2.1.1
* Support Raspberry Pi Pico 2 board
* Introduce GitHub Actions for build and release

## [0.8.1] - 2025-03-03
### Changed
Expand Down