Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.15
current_version = 1.1.16
commit = True
tag = False

Expand Down
125 changes: 92 additions & 33 deletions .github/workflows/release-controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v*.*.*'

permissions:
contents: write
Expand All @@ -19,59 +18,119 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
env:
REPO_NAME: ${{ github.event.repository.name }}
# set folder repository var \
# (settings->security->secrets-variables->actions->variables->repository) \
# or set default
FOLDER_TO_COMPRESS: 'docs'
REPO_FULL: ${{ github.repository }}
steps:
- name: Checkout repository
id: checkout_repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.12
id: setup_python
uses: actions/setup-python@v4
with:
python-version: 3.12
- name: Install dependencies
id: install_dependencies
- name: Generate Release Notes
id: release_notes
run: |
python -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install poetry
poetry lock
poetry install
TAG="${GITHUB_REF_NAME}"
PREV_TAG=$(git describe --tags --abbrev=0 "${TAG}^" 2>/dev/null || echo "")

if [ -z "$PREV_TAG" ]; then
COMMITS=$(git log "$TAG" --pretty=format:"%s")
else
COMMITS=$(git log "${PREV_TAG}..${TAG}" --pretty=format:"%s")
fi

FEATURES=""
FIXES=""
DOCS=""
REFACTORS=""
PERF=""
CHORES=""
STYLES=""
TESTS=""
OTHER=""

while IFS= read -r line; do
# Skip noise commits
case "$line" in
"Bump version:"*|"Merge branch"*|"Merge pull request"*) continue ;;
esac

# Strip emoji prefix if present
clean=$(echo "$line" | sed 's/^[^a-zA-Z]* *//')

# Parse conventional commit
if echo "$clean" | grep -qE '^(feat|fix|docs|style|refactor|perf|test|chore)(\([^)]+\))?:'; then
TYPE=$(echo "$clean" | sed -E 's/^(feat|fix|docs|style|refactor|perf|test|chore).*/\1/')
DESC=$(echo "$clean" | sed -E 's/^(feat|fix|docs|style|refactor|perf|test|chore)(\([^)]+\))?:\s*//')
# Remove versioning keyword suffix
DESC=$(echo "$DESC" | sed -E 's/\s*\[(minor|major|patch) candidate\]\s*$//')
SCOPE=$(echo "$clean" | sed -nE 's/^[a-z]+\(([^)]+)\):.*/\1/p')

if [ -n "$SCOPE" ]; then
ENTRY="- **${SCOPE}**: ${DESC}"
else
ENTRY="- ${DESC}"
fi

case "$TYPE" in
feat) FEATURES="${FEATURES}${ENTRY}\n" ;;
fix) FIXES="${FIXES}${ENTRY}\n" ;;
docs) DOCS="${DOCS}${ENTRY}\n" ;;
style) STYLES="${STYLES}${ENTRY}\n" ;;
refactor) REFACTORS="${REFACTORS}${ENTRY}\n" ;;
perf) PERF="${PERF}${ENTRY}\n" ;;
test) TESTS="${TESTS}${ENTRY}\n" ;;
chore) CHORES="${CHORES}${ENTRY}\n" ;;
esac
else
if [ -n "$clean" ]; then
OTHER="${OTHER}- ${clean}\n"
fi
fi
done <<< "$COMMITS"

# Build release notes body
BODY="## What's Changed\n\n"

[ -n "$FEATURES" ] && BODY="${BODY}### Features\n${FEATURES}\n"
[ -n "$FIXES" ] && BODY="${BODY}### Bug Fixes\n${FIXES}\n"
[ -n "$DOCS" ] && BODY="${BODY}### Documentation\n${DOCS}\n"
[ -n "$REFACTORS" ] && BODY="${BODY}### Refactors\n${REFACTORS}\n"
[ -n "$PERF" ] && BODY="${BODY}### Performance\n${PERF}\n"
[ -n "$STYLES" ] && BODY="${BODY}### Styles\n${STYLES}\n"
[ -n "$TESTS" ] && BODY="${BODY}### Tests\n${TESTS}\n"
[ -n "$CHORES" ] && BODY="${BODY}### Chores\n${CHORES}\n"
[ -n "$OTHER" ] && BODY="${BODY}### Other\n${OTHER}\n"

if [ -n "$PREV_TAG" ]; then
BODY="${BODY}**Full Changelog**: https://github.com/${REPO_FULL}/compare/${PREV_TAG}...${TAG}\n"
fi

# Write to output using delimiter
{
echo "body<<RELEASE_NOTES_EOF"
echo -e "$BODY"
echo "RELEASE_NOTES_EOF"
} >> "$GITHUB_OUTPUT"
env:
REPO_FULL: ${{ env.REPO_FULL }}
- name: Package Version
id: package_version
run: |
zip -r "${REPO_NAME}-${GITHUB_REF_NAME}.zip" \
{INSTALL,SECURITY,README,ICONS,CONTRIBUTING,CODE_OF_CONDUCT}.md \
requirements.txt .github scripts *adm* smtp-relay elastalert \
pyproject.toml
# "${FOLDER_TO_COMPRESS}"
env:
REPO_NAME: ${{ env.REPO_NAME }}
GITHUB_REF_NAME: ${{ github.ref_name }}
FOLDER_TO_COMPRESS: ${{ env.FOLDER_TO_COMPRESS }}
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: ${{ steps.release_notes.outputs.body }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload_release
uses: actions/upload-release-asset@v1
files: "${{ env.REPO_NAME }}-${{ github.ref_name }}.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: "${{ env.REPO_NAME }}-${{ github.ref_name }}.zip"
asset_name: "${{ env.REPO_NAME }}-${{ github.ref_name }}.zip"
asset_content_type: application/zip
26 changes: 18 additions & 8 deletions .github/workflows/version-controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
steps:
- name: Checkout Repository
id: checkout_repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
id: setup_python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Dependencies
Expand Down Expand Up @@ -61,18 +61,28 @@ jobs:
run: |
ls -la
git submodule add --force -b ${{ steps.determine_branch.outputs.current_branch }} https://github.com/JuanVilla424/scripts.git
# - name: Run Changelog Generator
# id: run_changelog
# run: |
# python scripts/generate_changelog/main.py
- name: Run Changelog Generator
id: run_changelog
run: |
python scripts/generate_changelog/main.py
- name: Commit Changelog Updates
id: commit_changelog
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add CHANGELOG.md || true
git diff --cached --quiet || git commit -m "docs(core): update changelog"
- name: Check for Forbidden Character
id: check_arrow
run: |
if [[ "${{ steps.get_commit.outputs.commit_message }}" == *"β†’"* && "${{ steps.get_commit.outputs.commit_message }}" == *"Bump version:"* ]]; then
COMMIT_MSG="${COMMIT_MESSAGE}"
if [[ "$COMMIT_MSG" == *"β†’"* && "$COMMIT_MSG" == *"Bump version:"* ]]; then
echo "contains_arrow=true" >> $GITHUB_OUTPUT
else
echo "contains_arrow=false" >> $GITHUB_OUTPUT
fi
env:
COMMIT_MESSAGE: ${{ steps.get_commit.outputs.commit_message }}
- name: Create Tag
id: create_tag
if: steps.check_arrow.outputs.contains_arrow == 'true'
Expand All @@ -98,7 +108,7 @@ jobs:
- name: Create Pull Request
id: create_pull_request
if: steps.check_arrow.outputs.contains_arrow == 'true' && github.ref != 'refs/heads/main'
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "scripts"
version = "1.1.15"
version = "1.1.16"
description = "CICD Core Scripts"
authors = ["B <g46327wsj1.marbling129@passinbox.com>"]
license = "GLPv3"
Expand Down