Skip to content

com30n/build-alfred-workflow

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Repository files navigation

Build an Alfred workflow

Assemble the files within a source directory into an Alfred workflow single package ready to be distributed.

The name of the output file is generated from the workflow name and version contained in the workflow's metadata.

Usage

Pre-requisites

This action needs a file named info.plist with the metadata of your workflow in the root of your repo. This file is automatically generated for you when exporting workflows via the Alfred GUI.

Inputs

  • workflow_dir: Directory containing the sources of the workflow (defaults to workflow)
  • exclude_patterns: List of excluded files/directories
  • template_files: List of comma separated paths to files that would be used to template your info.plist file.

Why it can be helpful?

let's imagine that you have a Script filter where you wrote your python code, but you would like to develop the code using an IDE like pycharm, so using the option you can form your workflow from several files.

Usage:

To be able to add content of the files into you should put a template string into info.plist with the following structure: TEMPLATE_THIS_[0-9]+.
For example, if you want to put content of two files into info.plist, you should set template_files: "example1.py,example2.py", and put the template strings to the info.plist

...
<string>TEMPLATE_THIS_1
</string>
...
<string>TEMPLATE_THIS_2
</string>
...

each file will correspond to each template accordingly: example1.py will replace TEMPLATE_THIS_1 and example2.py will replace TEMPLATE_THIS_2
also you can put one file several times, just put the same template string to several places:

...
<string>TEMPLATE_THIS_1
</string>
...
<string>TEMPLATE_THIS_2
</string>
...
<string>TEMPLATE_THIS_1
</string>
...

Outputs

  • workflow_file: The name of the created .alfredworkflow file

Example workflow

On every push to a tag matching the pattern v*, create a release with the workflow file attached:

name: Create Alfred Workflow

on:
  push:
    tags:
      - 'v*'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Build Alfred Workflow
        id: alfred_builder
        uses: com30n/build-alfred-workflow@v1
        with:
          workflow_dir: .
          exclude_patterns: '*.pyc *__pycache__/*'
          custom_version: ${{ github.ref_name }}
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1.1.4
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ github.ref }}
          draft: false
          prerelease: false
      - name: Upload Alfred Workflow
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: ${{ steps.alfred_builder.outputs.workflow_file }}
          asset_name: ${{ steps.alfred_builder.outputs.workflow_file }}
          asset_content_type: application/zip

Additional files

In addition to the files and folders contained in the workflow_dir some other files are also implicitily shipped within the target workflow_file. These files are searched for in the root directory and are silently ignored in case they don't exist:

  • info.plist (required)
  • icon.png
  • README, README.md
  • LICENSE

About

A GitHub Action to package Alfred workflows

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 76.5%
  • Shell 19.8%
  • Dockerfile 3.7%