Search code examples
pluginsyamlgithub-actionscicd

How to create GitHub actions workflow for the FlowLauncher plugin CI/CD?


I need a GitHub actions workflow for my FlowLauncher plugin. I copied the official FlowLauncher GitHub actions template and it occured errors. I fixed some weak points that could cause errors and ended up with the following code:

name: Publish Release

on:
  workflow_dispatch:
  push:
    branches: [ main ]
    paths-ignore:
      - .github/workflows/*

jobs:
  publish:
    runs-on: ubuntu-latest
    env:
      python_ver: '3.12.1'

    steps:
      - uses: actions/checkout@v3
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
      - name: get version
        id: version
        uses: notiz-dev/github-action-json-property@release
        with:
          path: 'plugin.json'
          prop_path: 'Version'
      - run: echo ${{steps.version.outputs.prop}}
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r ./requirements.txt -t ./lib
          zip -r Flow.Launcher.Plugin.MyPlugin.zip . -x '*.git*'
      - name: Publish
        if: success()
        uses: actions/create-release@v1
        with:
          files: 'Flow.Launcher.Plugin.MyPlugin.zip'
          tag_name: "v${{steps.version.outputs.prop}}"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

That occurs the following errors:

Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v3, actions/setup-python@v4, notiz-dev/github-action-json-property@release, softprops/action-gh-release@v1. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

and

The `python-version` input is not set. The version of Python currently in `PATH` will be used.

Solution

  • Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v3, actions/setup-python@v4, notiz-dev/github-action-json-property@release, softprops/action-gh-release@v1. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

    The latest version (supporting Node 20) for each of those versions currently (April 2nd 2024) are:

    • actions/checkout@v4.1.1
    • actions/setup-python@v5.1.0
    • notiz-dev/github-action-json-property@release : this one hasn't been updated, but there are PRs opened. So the warning will continue for now (except if you create a fork).
    • softprops/action-gh-release@v2.0.4

    The python-version input is not set. The version of Python currently in PATH will be used.

    You set an environment variable this way in your job:

    jobs:
      publish:
        runs-on: ubuntu-latest
        env:
          python_ver: '3.12.1'
        steps:
           ...
    

    However you are using ${{ matrix.python-version }} in your steps, which is related to matrix strategy (that you are not configuring here). You should use ${{ env.python-ver }} instead, as shown below:

    jobs:
      publish:
        runs-on: ubuntu-latest
        env:
          python_ver: '3.12.1'
        steps:
          - uses: actions/checkout@v4.1.1
          - name: Set up Python ${{ env.python-ver }}
            uses: actions/setup-python@v5.1.0
            with:
              python-version: ${{ env.python-ver }}