Skip to content

Release

Release #43

Workflow file for this run

name: Release
on:
workflow_dispatch:
push:
tags:
- "v*"
permissions:
contents: write
env:
PYTHON_VER: "3.10"
jobs:
package-and-release:
name: Package and Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify tag commit is on main
shell: bash
run: |
git fetch origin main --depth=1
if ! git branch -r --contains "$GITHUB_SHA" | grep -q "origin/main"; then
echo "Tag $GITHUB_REF_NAME is not on main." >&2
exit 1
fi
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VER }}
- name: Stage build files
id: stage
shell: bash
run: |
build_dir="$RUNNER_TEMP/build"
mkdir -p "$build_dir"
mv run.py "$build_dir/"
mv icon.png "$build_dir/"
mv plugin.json "$build_dir/"
mv SettingsTemplate.yaml "$build_dir/"
mv LICENSE "$build_dir/"
mv plugin "$build_dir/"
lib_dir="$build_dir/lib"
mkdir -p "$lib_dir"
echo "build_dir=$build_dir" >> "$GITHUB_OUTPUT"
echo "lib_dir=$lib_dir" >> "$GITHUB_OUTPUT"
- name: Install requirements into build/lib
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt --target "${{ steps.stage.outputs.lib_dir }}"
- name: Create release archive
id: archive
shell: bash
run: |
repo_name="${{ github.event.repository.name }}"
version="${{ github.ref_name }}"
version="${version#v}"
zip_name="${repo_name}-${version}.zip"
zip_path="$RUNNER_TEMP/$zip_name"
(
cd "${{ steps.stage.outputs.build_dir }}"
zip -r "$zip_path" .
)
echo "zip_path=$zip_path" >> "$GITHUB_OUTPUT"
- name: Release zip
uses: softprops/action-gh-release@v2
with:
files: ${{ steps.archive.outputs.zip_path }}
tag_name: ${{ github.ref_name }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}