From bddf932e054b76abb8774b300adcc65b6e0f0122 Mon Sep 17 00:00:00 2001 From: Huang Rui Date: Thu, 29 Feb 2024 11:51:51 +0800 Subject: [PATCH] github: Add workflow for KiCad Project Build and Release - Implement workflow to trigger on tag push - Add steps for setting up environment and dependencies - Extract base name from tag for directory-specific build - Compile KiCad project and copy artifacts to workspace - Create a GitHub Release with PDF, ZIP, and BIN artifacts Signed-off-by: Huang Rui --- .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..66d7cd8a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: KiCad Project Build and Release + +on: + push: + tags: + - '*' + +jobs: + build: + runs-on: ubuntu-22.04 + permissions: + contents: write + name: KiCad Project Build and Release + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Add KiCad Repository + run: | + sudo add-apt-repository ppa:kicad/kicad-8.0-releases + sudo apt update + - name: Cache Required Packages + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: cmake ninja-build kicad kicad-library-all + version: 1.0 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - run: pip install frugy + - name: Extract Tag Base Name + id: get_tag + run: | + TAG_NAME=${GITHUB_REF#refs/tags/} + BASE_NAME=$(echo $TAG_NAME | cut -d '_' -f 1) + echo "Full tag name: $TAG_NAME" + echo "Base name: $BASE_NAME" + echo "##[set-output name=tag_base_name;]$BASE_NAME" + - name: Build and Validate KiCad Project + run: | + PROJECT_DIRS="${{ steps.get_tag.outputs.tag_base_name }}" + for DIR in $PROJECT_DIRS; do + echo "Processing directory: $DIR" + pushd ${{github.workspace}}/$DIR + cmake -B ./build -G Ninja + cmake --build ./build + find ./build -name \*.pdf -exec cp {} ${{github.workspace}}/ \; + find ./build -name \*.zip -exec cp {} ${{github.workspace}}/ \; + find ./build -name \*.bin -exec cp {} ${{github.workspace}}/ \; + popd + done + - name: Create Release + uses: ncipollo/release-action@v1 + with: + artifacts: "*.pdf,*.zip,*.bin"