cellular-featherwing-pcb/.github/workflows/release.yml

132 lines
5.9 KiB
YAML

# MIT License
# Copyright (c) 2021 Neil Enns
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# This workflow generates documentation (PDFs, interactive BOMs, board images) and fabrication
# files for JLCPCB and PCBWay. The version number and date of the design is automatically
# updated in the schematic file and on the PCB based on the GitHub release version and date.
# To use this workflow in your own repo you need to edit the environment variables in the env: section
# below.
name: "KiBot - Release"
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Design version"
required: true
default: "pre-release"
jobs:
FabricationAndDocumentation:
runs-on: ubuntu-latest
env:
# Set this to your local timezone. See https://www.wikiwand.com/en/List_of_tz_database_time_zones for valid strings.
Timezone: America/Los_Angeles
# Set this to the output folder for all of the generated files. Unless you have a very
# good reason to change this you should leave it as KiBotOutput.
OutputFolder: "KiBotOutput"
# These are all the steps that generate the files.
steps:
# Check out the PCB design
- name: Checkout PCB design
uses: actions/checkout@v3
# Check out the custom component library for access to the 3D models.
# - name: Checkout component library
# uses: actions/checkout@v3
# with:
# repository: neilenns/kicad6-components
# path: KiCad6-Components
# Get the version of the GitHub release for use later. This is only valid
# when run in a release context
- name: Get GitHub release version
id: get_github_version
uses: battila7/get-version-action@v2
if: startsWith(github.ref, 'refs/tags/')
- name: Store GitHub release version
id: save_github_version
run: echo "version=${{ steps.get_github_version.outputs.version }}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/')
# Get the version from the workflow input. This is only valid
# when run manually as a workflow.
- name: Store workflow version
id: save_workflow_version
run: echo "version=${{ github.event.inputs.version }}" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/') == false
# Actually run KiBot to generate all the files. The KiBot script used is
# in the .kibot/release.kibot.yaml folder.
- name: Generate documentation and fabrication files
uses: INTI-CMNB/KiBot@v2_k6
with:
config: .kibot/release.kibot.yaml
dir: ${{ env.OutputFolder }}
schema: ${{ github.event.repository.name }}.kicad_sch
board: ${{ github.event.repository.name }}.kicad_pcb
# Install the zip command line tool to package up the output
- name: Install zip
uses: montudor/action-zip@v1
# Zip all the documentation. Any files in the BOM, PDFs, and Renders subfolder
# are automatically included.
- name: Zip documentation
run: zip -qq -r "../${{ github.event.repository.name }}-Documentation.zip" BOM PDFs Renders
working-directory: ${{ env.OutputFolder }}
# Zip the JLCPCB files. This is a special step for JLCPCB because there are gerbers (already zipped by KiBot),
# BOM, and position files for SMT fabrication.
- name: Zip JLCPCB fabrication files
run: zip -qq -r "../../${{ github.event.repository.name }}-JLCPCB.zip" ${{ github.event.repository.name }}-JLCPCB.zip ${{ github.event.repository.name }}_bom_jlc.csv ${{ github.event.repository.name }}_cpl_jlc.csv
working-directory: ${{ env.OutputFolder }}/JLCPCB
# Upload all the zip files to the release. Note that the PCBWay zip was automatically created by KiBot
# since it doesn't have BOM or position files associated (like JLCPCB does) so the path to the file
# to upload is slightly different.
# If you are copying this to your own repo you'll want to remove the upload of the MobiFlight-Configuration
# zip file.
- name: Upload release files
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
${{ env.OutputFolder }}/PDFs/${{ github.event.repository.name }}-schematic.pdf
${{ github.event.repository.name }}-Documentation.zip
${{ github.event.repository.name }}-JLCPCB.zip
${{ env.OutputFolder }}/PCBWay/${{ github.event.repository.name }}-PCBWay.zip
# Archive all the artifacts from output and attach to the action's results.
# This is so they're made available when this workflow is run manually from the
# GitHub actions page.
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: release_files
path: ${{ env.OutputFolder }}/**