mirror of
https://github.com/ivuorinen/actions.git
synced 2026-01-26 11:34:00 +00:00
feat: add GitHub Actions workflows for code quality and automation (#2)
This commit is contained in:
54
github-release/action.yml
Normal file
54
github-release/action.yml
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
# 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 }}"
|
||||
Reference in New Issue
Block a user