Skip to content

initial release

initial release #1

Workflow file for this run

name: GitHub Release
on:
push:
tags:
- "*"
jobs:
release:
name: Build & Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Debug File List
run: ls -R
- name: Find Readme File
id: find_readme
run: |
for file in readme.txt Readme.txt README.txt README.md Readme.md readme.md; do
if [ -f "$file" ]; then
echo "Readme file found: $file"
echo "readme_file=$file" >> $GITHUB_ENV
break
fi
done
source $GITHUB_ENV
if [ -z "$readme_file" ]; then
echo "::error::Readme file not found."
exit 1
fi
- name: Extract Release Notes
id: release_notes
run: |
changelog_section_start="== Changelog =="
readme_file="$readme_file"
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
plugin_version="${GITHUB_REF#refs/tags/}"
echo "Detected tag version: $plugin_version"
else
echo "::error::Workflow must be triggered by a tag push."
exit 1
fi
in_changelog=0
found_version=0
release_notes=""
while IFS= read -r line; do
if [[ "$line" == "$changelog_section_start" ]]; then
in_changelog=1
continue
fi
if [[ $in_changelog -eq 0 ]]; then
continue
fi
if [[ "$line" == "= ${plugin_version} =" ]]; then
found_version=1
continue
fi
if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^= [0-9]+\.[0-9]+\.[0-9]+ =$'; then
break
fi
if [[ $found_version -eq 1 ]] && echo "$line" | grep -qE '^\*'; then
release_notes+="${line}\n"
continue
fi
done < "$readme_file"
if [[ -z "$release_notes" ]]; then
echo "::error::Failed to extract release notes for version ${plugin_version}."
exit 1
fi
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
echo -e "$release_notes" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Create ZIP Archive
run: |
repo_name="${{ github.event.repository.name }}"
zip_name="${repo_name}.zip"
zip -r "$zip_name" . \
-x "*.git*" \
".github/*"
echo "ZIP_FILE=$zip_name" >> $GITHUB_ENV
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
body: ${{ env.RELEASE_NOTES }}
files: ${{ env.ZIP_FILE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}