Skip to content

Commit 50fbf71

Browse files
committed
Initial commit
0 parents  commit 50fbf71

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

.github/workflows/custopize.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: "CustoPiZe"
2+
3+
on:
4+
repository_dispatch:
5+
types: [octoprint_release]
6+
workflow_dispatch:
7+
inputs:
8+
octoprint_version:
9+
description: "OctoPrint version (leave empty to use latest stable release)"
10+
required: false
11+
default: ''
12+
13+
jobs:
14+
build:
15+
name: "Build"
16+
runs-on: ubuntu-latest
17+
steps:
18+
19+
- name: "⬇ Checkout"
20+
uses: actions/checkout@v2
21+
22+
- name: "🔎 Determine OctoPrint version"
23+
run: |
24+
if [[ "${{ github.event_name }}" = "repository_dispatch" ]]; then
25+
OCTOPRINT_VERSION="${{ github.event.client_payload.version }}"
26+
else
27+
OCTOPRINT_VERSION="${{ github.event.inputs.octoprint_version }}"
28+
fi
29+
30+
if [ -z "$OCTOPRINT_VERSION" ]; then
31+
OCTOPRINT_VERSION=$(curl https://pypi.org/pypi/OctoPrint/json -s | jq -r '.info.version')
32+
fi
33+
34+
# Make sure we have a published version
35+
curl -fsSL --output /dev/null --head https://pypi.org/pypi/OctoPrint/$OCTOPRINT_VERSION/ || exit 1
36+
37+
echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV
38+
39+
- name: "⬇ Download latest OctoPi"
40+
id: octopi_download
41+
run: |
42+
mkdir build
43+
cd build
44+
wget https://octopi.octoprint.org/latest -O octopi.zip
45+
46+
unzip octopi.zip
47+
rm octopi.zip
48+
49+
IMAGE=$(ls *.img | head -n 1)
50+
mv $IMAGE input.img
51+
52+
OCTOPI_VERSION=$(basename -s .img $IMAGE | awk -F"-" '{print $NF}')
53+
echo "OCTOPI_VERSION=$OCTOPI_VERSION" >> $GITHUB_ENV
54+
55+
- name: "🏗 Run CustoPiZer"
56+
run: |
57+
sudo modprobe loop
58+
docker run --rm --privileged \
59+
-e OCTOPRINT_VERSION=${{ env.OCTOPRINT_VERSION }} \
60+
-v ${{ github.workspace }}/build:/CustoPiZer/workspace \
61+
-v ${{ github.workspace }}/scripts:/CustoPiZer/workspace/scripts \
62+
ghcr.io/octoprint/custopizer:latest
63+
64+
- name: "📦 Package the image"
65+
run: |
66+
OCTOPI_VERSION="${{ env.OCTOPI_VERSION }}"
67+
OCTOPRINT_VERSION="${{ env.OCTOPRINT_VERSION }}"
68+
69+
IMAGE="octopi-$OCTOPI_VERSION-$OCTOPRINT_VERSION.img"
70+
echo "IMAGE=$IMAGE" >> $GITHUB_ENV
71+
72+
cd build
73+
mv output.img $IMAGE
74+
zip $IMAGE.zip $IMAGE
75+
md5sum $IMAGE.zip > $IMAGE.zip.md5
76+
sha256sum $IMAGE.zip > $IMAGE.zip.sha256
77+
78+
- name: "📝 Prepare release"
79+
run: |
80+
RELEASE_NAME="OctoPi ${{ env.OCTOPI_VERSION }} with OctoPrint ${{ env.OCTOPRINT_VERSION }}"
81+
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
82+
83+
RELEASE_TAG="${{ env.OCTOPI_VERSION }}.op${{ env.OCTOPRINT_VERSION }}"
84+
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
85+
86+
RELEASE_BODY=""
87+
(git rev-parse $RELEASE_TAG >/dev/null 2>&1) || RELEASE_BODY="Created with [CustoPiZer](https://github.com/OctoPrint/CustoPiZer)"
88+
89+
echo "RELEASE_BODY=$RELEASE_BODY" >> $GITHUB_ENV
90+
91+
- name: "🔖 Create release & attach assets"
92+
uses: softprops/action-gh-release@v1
93+
with:
94+
name: "${{ env.RELEASE_NAME }}"
95+
tag_name: "${{ env.RELEASE_TAG }}"
96+
body: "${{ env.RELEASE_BODY }}"
97+
files: |
98+
build/${{ env.IMAGE }}.zip
99+
build/${{ env.IMAGE }}.zip.md5
100+
build/${{ env.IMAGE }}.zip.sha256
101+
env:
102+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scripts/01-update-octoprint

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set -x
2+
set -e
3+
4+
export LC_ALL=C
5+
6+
source /common.sh
7+
install_cleanup_trap
8+
9+
if [ -n "$OCTOPRINT_VERSION" ]; then
10+
sudo -u pi /home/pi/oprint/bin/pip install -U OctoPrint==$OCTOPRINT_VERSION
11+
else
12+
sudo -u pi /home/pi/oprint/bin/pip install -U OctoPrint
13+
fi

0 commit comments

Comments
 (0)