@@ -32,11 +32,15 @@ jobs:
32
32
let version = '';
33
33
if (context.eventName === "respository_dispatch" && context.payload.type === "octopi_release") {
34
34
version = context.payload.client_payload.version;
35
+ console.log(`Version from repository dispatch: ${version}`);
35
36
} else if (context.eventName === "workflow_dispatch") {
36
37
version = context.payload.inputs.octopi_version;
38
+ console.log(`Version from workflow dispatch: ${version}`);
37
39
}
38
40
39
41
if (version) {
42
+ console.log(`Fetching release of ${version}`);
43
+
40
44
const query = `query {
41
45
repository(owner: "guysoft", name: "Octopi") {
42
46
release(tagName:"${version}") {
57
61
release = result.repository.release;
58
62
59
63
} else {
64
+ console.log("Fetching latest release");
65
+
60
66
const query = `query {
61
67
repository(owner:"guysoft", name:"OctoPi") {
62
68
latestRelease {
@@ -99,14 +105,17 @@ jobs:
99
105
100
106
- name : " 🔎 Determine OctoPrint version"
101
107
run : |
102
- if [[ "${{ github.event_name }}" = "repository_dispatch" ]]; then
108
+ if [[ "${{ github.event_name }}" = "repository_dispatch" && "${{ github.event.client_payload.type }}" = "octopi_release" ]]; then
103
109
OCTOPRINT_VERSION="${{ github.event.client_payload.version }}"
110
+ echo "Version from repository dispatch: $OCTOPRINT_VERSION"
104
111
else
105
112
OCTOPRINT_VERSION="${{ github.event.inputs.octoprint_version }}"
113
+ echo "Version from workflow dispatch: $OCTOPRINT_VERSION"
106
114
fi
107
115
108
116
if [ -z "$OCTOPRINT_VERSION" ]; then
109
117
OCTOPRINT_VERSION=$(curl https://pypi.org/pypi/OctoPrint/json -s | jq -r '.info.version')
118
+ echo "Version from PyPI: $OCTOPRINT_VERSION"
110
119
fi
111
120
112
121
# Make sure we have a published version
@@ -130,15 +139,13 @@ jobs:
130
139
mv $IMAGE input.img
131
140
132
141
- 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"
142
149
run : |
143
150
OCTOPI_VERSION="${{ env.OCTOPI_VERSION }}"
144
151
OCTOPRINT_VERSION="${{ env.OCTOPRINT_VERSION }}"
@@ -148,25 +155,7 @@ jobs:
148
155
149
156
cd build
150
157
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
163
158
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
-
170
159
- name : " 📝 Prepare release"
171
160
run : |
172
161
RELEASE_NAME="OctoPi ${{ env.OCTOPI_VERSION }} with OctoPrint ${{ env.OCTOPRINT_VERSION }}"
@@ -180,31 +169,24 @@ jobs:
180
169
181
170
echo "RELEASE_BODY=$RELEASE_BODY" >> $GITHUB_ENV
182
171
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 }}"
193
177
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 }}
208
190
209
191
- name : " 🔖 Create release & attach assets"
210
192
uses : softprops/action-gh-release@v1
@@ -215,9 +197,9 @@ jobs:
215
197
prerelease : ${{ contains(env.OCTOPRINT_VERSION, 'rc') }}
216
198
fail_on_unmatched_files : true
217
199
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
221
203
build/rpi-imager.json
222
204
env :
223
205
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments