Skip to content

Release WordPress Plugin #7

Release WordPress Plugin

Release WordPress Plugin #7

name: Release WordPress Plugin
on:
push:
tags:
- "*"
workflow_dispatch: # Allow manual triggering
inputs:
tag_name:
description: 'Tag name to rerun'
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Determine Tag Name
id: determine_tag
run: |
# Use the tag from either GITHUB_REF or the manual input
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
tag="${{ inputs.tag_name }}"
else
tag="${GITHUB_REF#refs/tags/}"
fi
echo "Tag: $tag"
echo "tag=$tag" >> $GITHUB_ENV
- name: Prepare Plugin ZIP
run: |
plugin_name="ootb-openstreetmap"
mkdir -p "$plugin_name"
# Create exclusion rules from `.distignore`
if [[ -f ".distignore" ]]; then
rsync_exclude_option="--exclude-from=.distignore"
else
rsync_exclude_option=""
fi
# Sync files but exclude the ZIP file itself and the output directory
rsync -av $rsync_exclude_option \
--exclude="${plugin_name}-${tag}.zip" \
--exclude="$plugin_name/" ./ "$plugin_name/"
# Create the ZIP
zip -r "${plugin_name}-${tag}.zip" "$plugin_name"
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "$tag" \
--title="Release $tag" \
--draft \
-- "ootb-openstreetmap-${tag}.zip"