mirror of
https://github.com/ivuorinen/actions.git
synced 2026-01-26 18:39:13 +00:00
55 lines
1.8 KiB
YAML
55 lines
1.8 KiB
YAML
---
|
|
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
|
|
name: GitHub Release
|
|
description: 'Creates a GitHub release with a version and changelog.'
|
|
author: 'Ismo Vuorinen'
|
|
|
|
branding:
|
|
icon: 'tag'
|
|
color: 'blue'
|
|
|
|
inputs:
|
|
version:
|
|
description: 'The version for the release.'
|
|
required: true
|
|
changelog:
|
|
description: 'The changelog or description for the release.'
|
|
required: false
|
|
default: ''
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Create GitHub Release with Autogenerated Changelog
|
|
if: ${{ inputs.changelog == '' }}
|
|
shell: bash
|
|
run: |
|
|
# Validate version format
|
|
if [[ ! "${{ inputs.version }}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[\w.]+)?(\+[\w.]+)?$ ]]; then
|
|
echo "Error: Invalid version format. Must follow semantic versioning."
|
|
exit 1
|
|
fi
|
|
# Escape special characters in inputs
|
|
VERSION=$(echo "${{ inputs.version }}" | sed 's/[&/\]/\\&/g')
|
|
gh release create ${{ inputs.version }}
|
|
--repo="${GITHUB_REPOSITORY}" \
|
|
--title="${{ inputs.version }}" \
|
|
--generate-notes
|
|
|
|
- name: Create GitHub Release with Custom Changelog
|
|
if: ${{ inputs.changelog != '' }}
|
|
shell: bash
|
|
run: |
|
|
# Validate version format
|
|
if [[ ! "${{ inputs.version }}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-[\w.]+)?(\+[\w.]+)?$ ]]; then
|
|
echo "Error: Invalid version format. Must follow semantic versioning."
|
|
exit 1
|
|
fi
|
|
# Escape special characters in inputs
|
|
VERSION=$(echo "${{ inputs.version }}" | sed 's/[&/\]/\\&/g')
|
|
CHANGELOG=$(echo "${{ inputs.changelog }}" | sed 's/[&/\]/\\&/g')
|
|
gh release create ${{ inputs.version }}
|
|
--repo="${GITHUB_REPOSITORY}" \
|
|
--title="${{ inputs.version }}" \
|
|
--notes="${{ inputs.changelog }}"
|