Skip to content

Build and Release a Plugin

OllisGit edited this page Nov 19, 2021 · 2 revisions

Build

To build your plugin you can use Travis (see https://github.com/OllisGit/OctoPrint-KnowledgeBase/wiki/DownloadCounter#setup-travis) or GitHub Actions (see following sections)

GitHub Action

You need to do the following steps:

  1. Create github-action.yml
  2. Create a RELEASE_TEMPLATE.md

1. Create a the following file .github/workflows/github-release-actions.yml (filename doesn't matter)

###
### Script for:
### - build a zip file of the needed files/directories 
### - extract the version number from setup.py
### - deploy a draft-release into github repository
###
name: Build Plugin Release - Action
on: [push]
jobs:
  Build-Release-ZIP-Action:
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository code
        uses: actions/checkout@v2

      - run: echo "Read current plugin version..."
      - run: export PLUGIN_VERSION=$(cat setup.py | grep 'plugin_version = "*"' | cut -d '"' -f2)
      - run: echo "Plugin Version  $PLUGIN_VERSION ${PLUGIN_VERSION}"

      - run: echo "Build ZIP"
      - run: zip -r master.zip * -i '\octoprint_*' 'translations' 'README.md' 'requirements.txt' 'setup.py'
      - name: List files in the repository
        run: |
          ls ${{ github.workspace }}

      - name: version
        run: echo "::set-output name=version::$(cat setup.py | grep 'plugin_version = "*"' | cut -d '"' -f2)"
        id: version

      - name: release
        uses: actions/create-release@v1
        id: create_release
        env:
          GITHUB_TOKEN: ${{ github.token }}
        with:
          draft: true
          prerelease: false
          release_name: V${{ steps.version.outputs.version }}-draft
          tag_name: ${{ steps.version.outputs.version }}-draft
          body_path: .github/workflows/RELEASE_TEMPLATE.md

      - name: upload master.zip to release
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ github.token }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: master.zip
          asset_name: master.zip
          asset_content_type: application/gzip

      - run: echo "🍏 This job's status is ${{ job.status }}."

2. Create a the following file .github/workflows/RELEASE_TEMPLATE.md

## [BugFix]
- #xxx

## [Enhancement]
- #xxx

## Counter
![downloaded](https://img.shields.io/github/downloads/OllisGit/OctoPrint-FilamentManager/xxx/total)

## Support my Efforts

This plugin, as well as my [other plugins](https://github.com/OllisGit/) were developed in my spare time.
If you like it, I would be thankful about a cup of coffee :)

[![More coffee, more code](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6SW5R6ZUKLB5E&source=url)

Release a plugin in your GitHub-Repository

After the draft-release is deployed adjust the release notes:

  • Tag
  • Version
  • Description: Change the tag number of the download-counter badge

Distribution

For OctoPrint-Distribution (publish in OctoPrint Plugin Repository) take a look here https://github.com/OllisGit/OctoPrint-KnowledgeBase/wiki/DistributePlugin