.github/workflows/download-firmware.yml #31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| download-firmware: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Get latest available version | |
| run: | | |
| INFO=$(curl -s https://api.qidi3dprinter.com/code/x_q_2_version_info) | |
| if [ -z "$INFO" ]; then | |
| echo "Failed to fetch version info" | |
| exit 1 | |
| fi | |
| # Sanitize JSON by removing tabs and newlines for environment variable | |
| INFO_SANITIZED=$(echo "$INFO" | tr -d '\t\n\r') | |
| echo "INFO=$INFO_SANITIZED" >> $GITHUB_ENV | |
| - name: Check if release exists | |
| id: check_release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| VERSION=$(echo "$INFO" | jq -r '.firmware.version') | |
| DESCRIPTION=$(echo "$INFO" | jq -r '.firmware.description.en_US') | |
| if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then | |
| echo "Failed to extract version from API response" | |
| exit 1 | |
| fi | |
| if [ -z "$DESCRIPTION" ] || [ "$DESCRIPTION" = "null" ]; then | |
| DESCRIPTION="Firmware update for QIDI 3D printer" | |
| fi | |
| # Check if release already exists | |
| if gh release view "$VERSION" >/dev/null 2>&1; then | |
| echo "Release $VERSION already exists" | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Release $VERSION does not exist" | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "DESCRIPTION=$DESCRIPTION" >> $GITHUB_OUTPUT | |
| - name: Download firmware | |
| if: steps.check_release.outputs.exists == 'false' | |
| run: | | |
| VERSION="${{ steps.check_release.outputs.VERSION }}" | |
| echo "Downloading firmware version $VERSION" | |
| wget "https://download_aws.qidi3dprinter.com/QD_Q2/Q2_$VERSION.zip" -O firmware.zip | |
| if [ ! -f "firmware.zip" ]; then | |
| echo "Failed to download firmware file" | |
| exit 1 | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Create release | |
| if: steps.check_release.outputs.exists == 'false' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.VERSION }} | |
| name: Firmware ${{ env.VERSION }} | |
| body: | | |
| ${{ steps.check_release.outputs.DESCRIPTION }} | |
| --- | |
| **Note:** The firmware.zip file is the property of QIDI Tech. Copyright © 2025 QIDI Tech All Rights Reserved. | |
| This repository only automates the distribution of official firmware releases. | |
| files: firmware.zip | |
| draft: false | |
| prerelease: false |