Skip to content

pioreactor_release #167

pioreactor_release

pioreactor_release #167

Workflow file for this run

name: "CustoPiZe"
on:
repository_dispatch:
types: pioreactor_release
workflow_dispatch:
inputs:
pioreactor_version:
description: "Pioreactor version"
required: true
default: ''
jobs:
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- name: "⬇ Checkout"
uses: actions/checkout@v4
- name: "🔎 Determine Pioreactor version"
run: |
if [[ "${{ github.event_name }}" = "repository_dispatch" && "${{ github.event.action }}" = "pioreactor_release" ]]; then
PIOREACTOR_VERSION="${{ github.event.client_payload.version }}"
echo "Version from repository dispatch: $PIOREACTOR_VERSION"
else
PIOREACTOR_VERSION="${{ github.event.inputs.pioreactor_version }}"
echo "Version from workflow dispatch: $PIOREACTOR_VERSION"
fi
echo "PIOREACTOR_VERSION=$PIOREACTOR_VERSION" >> $GITHUB_ENV
- name: "⬇ Download RPi image"
id: download_rpi_image
run: |
mkdir -p build
cd build
wget https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2024-11-19/2024-11-19-raspios-bookworm-armhf-lite.img.xz -q -O input.img.xz
unxz -f input.img.xz
- name: "📝 Prepare release"
run: |
now=$(date +"%Y%m%d%H%M%S")
RELEASE_NAME="Pioreactor ${{ env.PIOREACTOR_VERSION }} (build $now)"
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
RELEASE_TAG="${{ env.PIOREACTOR_VERSION }}"
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
# release body
cat <<EOF > ./build/release.md
* Pioreactor ${{ env.PIOREACTOR_VERSION }}
Created with [CustoPiZer](https://github.com/Pioreactor/CustoPiZer)
<!-- mark:untested -->
EOF
- name: "🏗 Run CustoPiZer LW"
uses: Pioreactor/CustoPiZer@pioreactor
with:
workspace: "${{ github.workspace }}/build"
scripts: "${{ github.workspace }}/workspace/scripts"
config: "${{ github.workspace }}/config.local"
environment: '{ "PIO_VERSION": "${{ env.PIOREACTOR_VERSION }}", "LEADER": 1, "WORKER": 1, "HEADLESS": 1, "CUSTOPIZER_GIT_COMMIT": "${{ github.sha }}"}'
- name: "✏ Rename image LW"
run: |
IMAGE_LEADER_WORKER="pioreactor_leader_worker.img"
echo "IMAGE_LEADER_WORKER=$IMAGE_LEADER_WORKER" >> $GITHUB_ENV
cd build
mv output.img $IMAGE_LEADER_WORKER
- name: "📦 Package the image LW"
id: package-image-lw
uses: OctoPrint/actions/package-rpi-image@main
with:
image_path: "build/${{ env.IMAGE_LEADER_WORKER }}"
- name: 📨 Export zip name to env LW
run: |
IMAGE_LEADER_WORKER_URL=https://github.com/Pioreactor/CustoPiZer/releases/download/${{ env.RELEASE_TAG }}/${{ steps.package-image-lw.outputs.zip_name }}
echo "IMAGE_LEADER_WORKER_ZIP=${{ steps.package-image-lw.outputs.zip_name }}" >> $GITHUB_ENV
echo "IMAGE_LEADER_WORKER_URL=$IMAGE_LEADER_WORKER_URL" >> $GITHUB_ENV
echo "Link to leader-worker image: $IMAGE_LEADER_WORKER_URL" >> $GITHUB_STEP_SUMMARY
- name: "🏗 Run CustoPiZer L"
uses: Pioreactor/CustoPiZer@pioreactor
with:
workspace: "${{ github.workspace }}/build"
scripts: "${{ github.workspace }}/workspace/scripts"
config: "${{ github.workspace }}/config.local"
environment: '{ "PIO_VERSION": "${{ env.PIOREACTOR_VERSION }}", "LEADER": 1, "WORKER": 0, "HEADLESS": 1, "CUSTOPIZER_GIT_COMMIT": "${{ github.sha }}"}'
- name: "✏ Rename image L"
run: |
IMAGE_LEADER="pioreactor_leader.img"
echo "IMAGE_LEADER=$IMAGE_LEADER" >> $GITHUB_ENV
cd build
mv output.img $IMAGE_LEADER
- name: "📦 Package the image L"
id: package-image-l
uses: OctoPrint/actions/package-rpi-image@main
with:
image_path: "build/${{ env.IMAGE_LEADER }}"
- name: 📨 Export zip name to env L
run: |
IMAGE_LEADER_URL=https://github.com/Pioreactor/CustoPiZer/releases/download/${{ env.RELEASE_TAG }}/${{ steps.package-image-l.outputs.zip_name }}
echo "IMAGE_LEADER_ZIP=${{ steps.package-image-l.outputs.zip_name }}" >> $GITHUB_ENV
echo "IMAGE_LEADER_URL=$IMAGE_LEADER_URL" >> $GITHUB_ENV
echo "Link to leader image: $IMAGE_LEADER_URL" >> $GITHUB_STEP_SUMMARY
- name: "🏗 Run CustoPiZer W"
uses: Pioreactor/CustoPiZer@pioreactor
with:
workspace: "${{ github.workspace }}/build"
scripts: "${{ github.workspace }}/workspace/scripts"
config: "${{ github.workspace }}/config.local"
environment: '{ "PIO_VERSION": "${{ env.PIOREACTOR_VERSION }}", "LEADER": 0, "WORKER": 1, "HEADLESS": 1, "CUSTOPIZER_GIT_COMMIT": "${{ github.sha }}" }'
- name: "✏ Rename image W"
run: |
IMAGE_WORKER="pioreactor_worker.img"
echo "IMAGE_WORKER=$IMAGE_WORKER" >> $GITHUB_ENV
cd build
mv output.img $IMAGE_WORKER
- name: "📦 Package the image W"
id: package-image-w
uses: OctoPrint/actions/package-rpi-image@main
with:
image_path: "build/${{ env.IMAGE_WORKER }}"
- name: 📨 Export zip name to env W
run: |
echo "IMAGE_WORKER_ZIP=${{ steps.package-image-w.outputs.zip_name }}" >> $GITHUB_ENV
echo "IMAGE_WORKER_URL=https://github.com/Pioreactor/CustoPiZer/releases/download/${{ env.RELEASE_TAG }}/${{ steps.package-image-w.outputs.zip_name }}" >> $GITHUB_ENV
echo "Link to worker image: $IMAGE_WORKER_URL" >> $GITHUB_STEP_SUMMARY
- name: "🔖 Create release & attach assets"
uses: softprops/action-gh-release@v1
if: github.event_name == 'repository_dispatch'
with:
name: "${{ env.RELEASE_NAME }}"
tag_name: "${{ env.RELEASE_TAG }}"
body_path: "build/release.md"
prerelease: ${{ contains(env.PIOREACTOR_VERSION, 'rc') }}
fail_on_unmatched_files: true
files: |
build/${{ env.IMAGE_LEADER_WORKER_ZIP }}
build/${{ env.IMAGE_LEADER_WORKER_ZIP }}.md5
build/${{ env.IMAGE_LEADER_WORKER_ZIP }}.sha256
build/${{ env.IMAGE_LEADER_ZIP }}
build/${{ env.IMAGE_LEADER_ZIP }}.md5
build/${{ env.IMAGE_LEADER_ZIP }}.sha256
build/${{ env.IMAGE_WORKER_ZIP }}
build/${{ env.IMAGE_WORKER_ZIP }}.md5
build/${{ env.IMAGE_WORKER_ZIP }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}