@@ -32,11 +32,15 @@ jobs:
3232 let version = '';
3333 if (context.eventName === "respository_dispatch" && context.payload.type === "octopi_release") {
3434 version = context.payload.client_payload.version;
35+ console.log(`Version from repository dispatch: ${version}`);
3536 } else if (context.eventName === "workflow_dispatch") {
3637 version = context.payload.inputs.octopi_version;
38+ console.log(`Version from workflow dispatch: ${version}`);
3739 }
3840
3941 if (version) {
42+ console.log(`Fetching release of ${version}`);
43+
4044 const query = `query {
4145 repository(owner: "guysoft", name: "Octopi") {
4246 release(tagName:"${version}") {
5761 release = result.repository.release;
5862
5963 } else {
64+ console.log("Fetching latest release");
65+
6066 const query = `query {
6167 repository(owner:"guysoft", name:"OctoPi") {
6268 latestRelease {
@@ -99,14 +105,17 @@ jobs:
99105
100106 - name : " 🔎 Determine OctoPrint version"
101107 run : |
102- if [[ "${{ github.event_name }}" = "repository_dispatch" ]]; then
108+ if [[ "${{ github.event_name }}" = "repository_dispatch" && "${{ github.event.client_payload.type }}" = "octopi_release" ]]; then
103109 OCTOPRINT_VERSION="${{ github.event.client_payload.version }}"
110+ echo "Version from repository dispatch: $OCTOPRINT_VERSION"
104111 else
105112 OCTOPRINT_VERSION="${{ github.event.inputs.octoprint_version }}"
113+ echo "Version from workflow dispatch: $OCTOPRINT_VERSION"
106114 fi
107115
108116 if [ -z "$OCTOPRINT_VERSION" ]; then
109117 OCTOPRINT_VERSION=$(curl https://pypi.org/pypi/OctoPrint/json -s | jq -r '.info.version')
118+ echo "Version from PyPI: $OCTOPRINT_VERSION"
110119 fi
111120
112121 # Make sure we have a published version
@@ -130,15 +139,13 @@ jobs:
130139 mv $IMAGE input.img
131140
132141 - name : " 🏗 Run CustoPiZer"
133- run : |
134- sudo modprobe loop
135- docker run --rm --privileged \
136- -e OCTOPRINT_VERSION=${{ env.OCTOPRINT_VERSION }} \
137- -v ${{ github.workspace }}/build:/CustoPiZer/workspace \
138- -v ${{ github.workspace }}/scripts:/CustoPiZer/workspace/scripts \
139- ghcr.io/octoprint/custopizer:latest
140-
141- - name : " 📦 Package the image"
142+ uses : OctoPrint/CustoPiZer@main
143+ with :
144+ workspace : " ${{ github.workspace }}/build"
145+ scripts : " ${{ github.workspace }}/scripts"
146+ environment : ' { "OCTOPRINT_VERSION": "${{ env.OCTOPRINT_VERSION }}" }'
147+
148+ - name : " ✏ Rename image"
142149 run : |
143150 OCTOPI_VERSION="${{ env.OCTOPI_VERSION }}"
144151 OCTOPRINT_VERSION="${{ env.OCTOPRINT_VERSION }}"
@@ -148,25 +155,7 @@ jobs:
148155
149156 cd build
150157 mv output.img $IMAGE
151- md5sum $IMAGE > $IMAGE.md5
152- sha256sum $IMAGE > $IMAGE.sha256
153-
154- IMAGE_SHA256=`cat $IMAGE.sha256 | cut -d ' ' -f 1`
155- echo "IMAGE_SHA256=$IMAGE_SHA256" >> $GITHUB_ENV
156-
157- IMAGE_SIZE=`stat -c %s $IMAGE`
158- echo "IMAGE_SIZE=$IMAGE_SIZE" >> $GITHUB_ENV
159-
160- zip $IMAGE.zip $IMAGE
161- md5sum $IMAGE.zip > $IMAGE.zip.md5
162- sha256sum $IMAGE.zip > $IMAGE.zip.sha256
163158
164- ZIP_SHA256=`cat $IMAGE.zip.sha256 | cut -d ' ' -f 1`
165- echo "ZIP_SHA256=$ZIP_SHA256" >> $GITHUB_ENV
166-
167- ZIP_SIZE=`stat -c %s $IMAGE.zip`
168- echo "ZIP_SIZE=$ZIP_SIZE" >> $GITHUB_ENV
169-
170159 - name : " 📝 Prepare release"
171160 run : |
172161 RELEASE_NAME="OctoPi ${{ env.OCTOPI_VERSION }} with OctoPrint ${{ env.OCTOPRINT_VERSION }}"
@@ -180,31 +169,24 @@ jobs:
180169
181170 echo "RELEASE_BODY=$RELEASE_BODY" >> $GITHUB_ENV
182171
183- - name : " 📝 Prepare rpi-imager json snippet"
184- run : |
185- IMAGE_SHA256="${{ env.IMAGE_SHA256 }}"
186- ZIP_SHA256="${{ env.ZIP_SHA256 }}"
187- IMAGE_SIZE="${{ env.IMAGE_SIZE }}"
188- ZIP_SIZE="${{ env.ZIP_SIZE }}"
189-
190- NAME="${{ env.RELEASE_NAME }}"
191- URL="https://github.com/OctoPrint/OctoPi-UpToDate/releases/download/${{ env.RELEASE_TAG }}/${{ env.IMAGE }}.zip"
192- DATE=`date '+%Y-%m-%d'`
172+ - name : " 📦 Package the image"
173+ id : package-image
174+ uses : OctoPrint/actions/package-rpi-image@main
175+ with :
176+ image_path : " build/${{ env.IMAGE }}"
193177
194- cd build
195- cat > rpi-imager.json <<EOF
196- {
197- "name": "$NAME",
198- "description": "A Raspberry Pi distribution for 3d printers. Ships OctoPrint ${{ env.OCTOPRINT_VERSION }} out-of-the-box.",
199- "url": "$URL",
200- "icon": "https://octopi.octoprint.org/rpi-imager.png",
201- "release_date": "$DATE",
202- "extract_size": $IMAGE_SIZE,
203- "extract_sha256": "$IMAGE_SHA256",
204- "image_download_size": $ZIP_SIZE,
205- "image_download_sha256": "$ZIP_SHA256"
206- }
207- EOF
178+ - name : " 🆕 Generate rpi-imager.json snippet"
179+ uses : OctoPrint/actions/rpi-imager-snippet@main
180+ with :
181+ name : " ${{ env.RELEASE_NAME }}"
182+ description : " A Raspberry Pi distribution for 3d printers. Ships OctoPrint ${{ env.OCTOPRINT_VERSION }} out-of-the-box."
183+ icon : " https://octopi.octoprint.org/rpi-imager.png"
184+ url : " https://github.com/OctoPrint/OctoPi-UpToDate/releases/download/${{ env.RELEASE_TAG }}/${{ steps.package-image.outputs.zip_name }}"
185+ output : " build/rpi-imager.json"
186+ image_sha256 : ${{ steps.package-image.outputs.image_sha256 }}
187+ image_size : ${{ steps.package-image.outputs.image_size }}
188+ zip_sha256 : ${{ steps.package-image.outputs.zip_sha256 }}
189+ zip_size : ${{ steps.package-image.outputs.zip_size }}
208190
209191 - name : " 🔖 Create release & attach assets"
210192 uses : softprops/action-gh-release@v1
@@ -215,9 +197,9 @@ jobs:
215197 prerelease : ${{ contains(env.OCTOPRINT_VERSION, 'rc') }}
216198 fail_on_unmatched_files : true
217199 files : |
218- build/${{ env.IMAGE }}.zip
219- build/${{ env.IMAGE }}.zip .md5
220- build/${{ env.IMAGE }}.zip .sha256
200+ build/${{ steps.package-image.outputs.zip_name }}
201+ build/${{ steps.package-image.outputs.zip_name }}.md5
202+ build/${{ steps.package-image.outputs.zip_name }}.sha256
221203 build/rpi-imager.json
222204 env :
223205 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments