Skip to content

Update ci, update so version armf is downloaded and not arm64 #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 18 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build Image

on:
on:
push:
branches:
- '*'
Expand All @@ -18,26 +18,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: "⬇ Checkout"
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: "🔎 Determine OctoPi version"
uses: actions/github-script@v4
uses: actions/github-script@v7
with:
script: |
let release = null;

let version = '';
if (context.eventName === "respository_dispatch" && context.action === "octopi_release") {
if (context.eventName === "repository_dispatch" && context.action === "octopi_release") {
version = context.payload.client_payload.version;
console.log(`Version from repository dispatch: ${version}`);
} else if (context.eventName === "workflow_dispatch") {
version = context.payload.inputs.octopi_version;
console.log(`Version from workflow dispatch: ${version}`);
}

if (version) {
console.log(`Fetching release of ${version}`);

const query = `query {
repository(owner: "guysoft", name: "Octopi") {
release(tagName:"${version}") {
Expand All @@ -51,15 +48,11 @@ jobs:
}
}
}`;

const result = await github.graphql(query);
console.log({result});

release = result.repository.release;

} else {
console.log("Fetching latest release");

const query = `query {
repository(owner:"guysoft", name:"OctoPi") {
latestRelease {
Expand All @@ -73,30 +66,25 @@ jobs:
}
}
}`;

const result = await github.graphql(query);
console.log({result});

release = result.repository.latestRelease;
}

if (!release || !release.tagName || !release.releaseAssets || !release.releaseAssets.nodes) core.setFailed("Could not find OctoPi release");

const octopiVersion = release.tagName;

let octopiUrl = null;
for (const asset of release.releaseAssets.nodes) {
if (asset.name.startsWith("octopi-") && asset.name.endsWith(".zip")) {
octopiUrl = asset.downloadUrl;
break;
if (asset.name.startsWith("octopi-") &&
asset.name.endsWith(".zip") &&
!asset.name.includes("arm64") &&
(asset.name.includes("armhf") || !asset.name.includes("arm"))) {
octopiUrl = asset.downloadUrl;
break;
}
}

if (!octopiUrl) core.setFailed("Could not find OctoPi download URL");

console.log(`OctoPi version: ${octopiVersion}`)
console.log(`OctoPi download URL: ${octopiUrl}`)

core.exportVariable("OCTOPI_VERSION", octopiVersion)
core.exportVariable("OCTOPI_URL", octopiUrl)

Expand All @@ -109,7 +97,6 @@ jobs:

unzip octopi.zip
rm octopi.zip

IMAGE=$(ls *.img | head -n 1)
mv $IMAGE input.img

Expand All @@ -118,7 +105,7 @@ jobs:
with:
workspace: "${{ github.workspace }}/build"
scripts: "${{ github.workspace }}/src/scripts"
config: "${{ github.workspace }}/src/config"
config: "${{ github.workspace }}/src/config"

- name: "✏ Rename image"
run: |
Expand All @@ -128,7 +115,6 @@ jobs:
IMAGE="octopi-$OCTOPI_VERSION-klipper-$NOW"
echo "IMAGE=$IMAGE" >> $GITHUB_ENV
echo "NOW=$NOW" >> $GITHUB_ENV

cd build
mv output.img $IMAGE.img

Expand All @@ -137,13 +123,10 @@ jobs:
run: |
RELEASE_NAME="OctoPi ${{ env.OCTOPI_VERSION }} with latest Klipper"
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV

RELEASE_TAG="${{ env.OCTOPI_VERSION }}.klipper.${{ env.NOW }}"
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV

RELEASE_BODY=""
(git rev-parse $RELEASE_TAG >/dev/null 2>&1) || RELEASE_BODY="Created with [CustoPiZer](https://github.com/OctoPrint/CustoPiZer)"

echo "RELEASE_BODY=$RELEASE_BODY" >> $GITHUB_ENV

- name: "📦 Package the image"
Expand All @@ -169,7 +152,7 @@ jobs:

- name: "🔖 Create release & attach assets"
if: github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
name: "${{ env.RELEASE_NAME }}"
tag_name: "${{ env.RELEASE_TAG }}"
Expand All @@ -185,11 +168,12 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "⬆ Upload build artifact"
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: github.event_name == 'push'
with:
name: ${{ env.IMAGE }}
path: build/${{ env.IMAGE }}.img

- name: "🔖 Generate rpi-imager json"
uses: OctoPrint/actions/rpi-imager-json@main
with:
Expand All @@ -199,14 +183,15 @@ jobs:
output: ./rpi-imager.json
nameStable: "OctoPi-Klipper (stable)"
namePrerelease: "OctoPi-Klipper (prerelease)"

- name: "⬆ Publish Files To rpi-imager"
if: github.event_name == 'repository_dispatch' || github.event_name == 'workflow_dispatch'
id: upload
uses: Creepios/sftp-action@v1.0.3
uses: wangyucode/sftp-upload-action@v2.0.2
with:
host: ${{ secrets.FTP_HOST }}
port: 22
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
localPath: './rpi-imager.json'
remotePath: '/rpi-imager/rpi-imager-octoklipperpi.json'
localDir: './rpi-imager.json'
remoteDir: '/rpi-imager/rpi-imager-octoklipperpi.json'
4 changes: 2 additions & 2 deletions src/config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# enlarge image by 100MB prior to customization
EDITBASE_IMAGE_ENLARGEROOT=2000
# enlarge image by 3000MB prior to customization
EDITBASE_IMAGE_ENLARGEROOT=3000

# shrink image to minimum size plus 20MB after customization
EDITBASE_IMAGE_RESIZEROOT=20
5 changes: 4 additions & 1 deletion src/scripts/01-update-octoprint
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ export LC_ALL=C
source /common.sh
install_cleanup_trap

sudo -u pi /home/pi/oprint/bin/pip install -U OctoPrint
OCTOPI_OPT_FOLDER=/opt/octopi
OCTOPI_OCTOPRINT_FOLDER="${OCTOPI_OPT_FOLDER}"/oprint
PIP="${OCTOPI_OCTOPRINT_FOLDER}"/bin/pip
sudo -u pi "${PIP}" install -U OctoPrint
18 changes: 12 additions & 6 deletions src/scripts/03-install-klipper
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ install_cleanup_trap
[ -n "$KLIPPER_OCTOKLIPPER_URL" ] || KLIPPER_OCTOKLIPPER_URL="https://github.com/thelastWallE/OctoprintKlipperPlugin/archive/master.zip"

# Install Klipper
apt-get -y --allow-downgrades --allow-remove-essential --allow-change-held-packages install virtualenv python-dev libffi-dev build-essential libncurses-dev libusb-dev avrdude gcc-avr binutils-avr avr-libc stm32flash dfu-util libnewlib-arm-none-eabi gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0

pushd /home/pi
apt-get -y --allow-downgrades --allow-remove-essential --allow-change-held-packages install virtualenv python3 python3-dev libffi-dev build-essential libncurses-dev libusb-dev avrdude gcc-avr binutils-avr avr-libc stm32flash dfu-util libnewlib-arm-none-eabi gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0

OCTOPI_OPT_FOLDER=/opt/octopi
OCTOPI_OCTOPRINT_FOLDER="${OCTOPI_OPT_FOLDER}"/oprint
PIP="${OCTOPI_OCTOPRINT_FOLDER}"/bin/pip
chown pi:pi "${OCTOPI_OPT_FOLDER}"
chmod g+s /opt/octopi "${OCTOPI_OPT_FOLDER}"
chmod u+s /opt/octopi "${OCTOPI_OPT_FOLDER}"
pushd "${OCTOPI_OPT_FOLDER}"
# Mostly taken from klipper/scripts/install-octopi.sh
sudo -u pi git clone -b "$KLIPPER_BRANCH" --depth $KLIPPER_DEPTH "$KLIPPER_REPO" klipper
sudo -u pi virtualenv -p python2 klippy-env
sudo -u pi virtualenv -p python3 klippy-env
sudo -u pi klippy-env/bin/pip install -r klipper/scripts/klippy-requirements.txt

cp klipper/scripts/klipper-start.sh /etc/init.d/klipper
Expand All @@ -46,7 +52,7 @@ cp /files/klipper/default /etc/default/klipper
chmod 644 /etc/default/klipper

# Install plugin
sudo -u pi /home/pi/oprint/bin/pip install "${KLIPPER_OCTOKLIPPER_URL}"
sudo -u pi "${PIP}" install "${KLIPPER_OCTOKLIPPER_URL}"

# Merge config
sudo -u pi /home/pi/oprint/bin/python /files/merge-settings.py /files/octoprint/config.yaml /home/pi/.octoprint/config.yaml
sudo -u pi "${OCTOPI_OCTOPRINT_FOLDER}"/bin/python /files/merge-settings.py /files/octoprint/config.yaml /home/pi/.octoprint/config.yaml
17 changes: 0 additions & 17 deletions src/scripts/90-install-user-fix

This file was deleted.

52 changes: 0 additions & 52 deletions src/scripts/files/user-fix

This file was deleted.

17 changes: 0 additions & 17 deletions src/scripts/files/user-fix.service

This file was deleted.