From 5c38211e60366d3c2a18c233e6909bde95c979d1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 05:59:28 +0000 Subject: [PATCH 1/4] Initial plan From faeb0c2739cd64f63dfd5c0272c5bad268842594 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 06:04:44 +0000 Subject: [PATCH 2/4] Add missing inputs and README update functionality Co-authored-by: thoughtparametersllc <194255310+thoughtparametersllc@users.noreply.github.com> --- CHANGELOG.md | 24 ++++++++++--- README.md | 19 +++++++++- action.yml | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 133 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 179577d..d806586 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- `generate-badges` input to control badge generation (default: false) +- `update-readme` input to automatically update README with badges (default: false) +- `readme-path` input to specify README file location (default: README.md) +- `badge-style` input to choose between relative paths or GitHub URLs (default: path) +- Automatic README update functionality with marker support +- Badge markers for controlled placement in README files + +### Changed +- Badge generation is now opt-in via `generate-badges` input instead of always running +- README updates are now opt-in via `update-readme` input +- Improved badge generation logic with better error handling + +### Fixed +- Aligned action.yml inputs with documented features in README.md +- Corrected CHANGELOG.md version history + +## [0.0.25] - 2025-11-19 + ### Added - Comprehensive GitHub workflows for CI/CD - Workflow to test all GitHub Action features @@ -65,12 +84,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Changelog validation in release process - Security audit workflow with Dependabot - Lint and test workflow for PRs and pushes - -## [1.0.0] - Previous Release - -### Added - Initial Python linting action with Pylint, Black, and MyPy support -- Badge generation and automatic README updates - Flexible Python version support - Custom requirements file support - Comprehensive linting with detailed reporting diff --git a/README.md b/README.md index 1fd894a..069aa06 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ GitHub Action to perform Python linting with Black, Pylint, and MyPy. ### Basic Example +The basic usage runs Pylint, Black, and MyPy on your code. Badge generation is disabled by default. + ```yaml - name: Python Linting uses: thoughtparametersllc/python-linting@v1 @@ -57,7 +59,22 @@ When `generate-badges` is enabled, SVG badges will be automatically generated an When `update-readme` is enabled, the action will automatically insert badge references into your README.md: - Badges are inserted after the title with special markers - You can customize the README path and badge style (relative paths or GitHub URLs) -- The script preserves existing content and only updates the badge section +- The action preserves existing content and only updates the badge section +- **Important**: Your workflow needs write permissions for contents to commit badges: + ```yaml + permissions: + contents: write + ``` + +**Badge Markers** (optional - for controlled placement): + +You can add these markers to your README.md to control where badges are inserted: +```markdown + + +``` + +If markers are not present, badges will be automatically inserted after the first heading. **Manual Badge References** (if not using `update-readme`): diff --git a/action.yml b/action.yml index e094455..b769b80 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,26 @@ inputs: required: false default: '.github/badges' + generate-badges: + description: Generate and commit SVG badges to the repository. Defaults to false. + required: false + default: 'false' + + update-readme: + description: Automatically update README.md with badge references. Defaults to false. + required: false + default: 'false' + + readme-path: + description: Path to README.md file to update with badges. Defaults to README.md. + required: false + default: 'README.md' + + badge-style: + description: Badge style - 'url' for GitHub URLs or 'path' for relative paths. Defaults to path. + required: false + default: 'path' + runs: using: composite steps: @@ -305,7 +325,7 @@ runs: - name: Generate SVG Badges id: generate-badges - if: steps.install-linting-tools.outcome == 'success' && always() + if: steps.install-linting-tools.outcome == 'success' && inputs.generate-badges == 'true' && always() run: | if [ test -d "${{ inputs.badge-directory }}" ]; then echo "::notice file=action.yml,line=170::Badge directory exists: ${{ inputs.badge-directory }}" @@ -380,6 +400,75 @@ runs: shell: bash continue-on-error: true + - name: Update README with Badges + id: update-readme + if: steps.generate-badges.outcome == 'success' && inputs.update-readme == 'true' + run: | + README_FILE="${{ inputs.readme-path }}" + BADGE_DIR="${{ inputs.badge-directory }}" + BADGE_STYLE="${{ inputs.badge-style }}" + + echo "::notice file=action.yml,line=398::Updating README with badge references" + + # Check if README exists + if [ ! -f "$README_FILE" ]; then + echo "::warning file=action.yml,line=402::README file not found: $README_FILE" + exit 0 + fi + + # Define badge markers + MARKER_START="" + MARKER_END="" + + # Generate badge references based on style + if [ "$BADGE_STYLE" == "url" ]; then + # Use GitHub raw URLs + REPO="${{ github.repository }}" + BRANCH="${{ github.ref_name }}" + PYLINT_BADGE="![Pylint](https://raw.githubusercontent.com/$REPO/$BRANCH/$BADGE_DIR/pylint.svg)" + BLACK_BADGE="![Black](https://raw.githubusercontent.com/$REPO/$BRANCH/$BADGE_DIR/black.svg)" + MYPY_BADGE="![MyPy](https://raw.githubusercontent.com/$REPO/$BRANCH/$BADGE_DIR/mypy.svg)" + else + # Use relative paths + PYLINT_BADGE="![Pylint]($BADGE_DIR/pylint.svg)" + BLACK_BADGE="![Black]($BADGE_DIR/black.svg)" + MYPY_BADGE="![MyPy]($BADGE_DIR/mypy.svg)" + fi + + # Check if markers exist + if grep -q "$MARKER_START" "$README_FILE" && grep -q "$MARKER_END" "$README_FILE"; then + echo "::notice file=action.yml,line=426::Updating existing badge section in README" + + # Create badge content + BADGE_CONTENT="$MARKER_START\n$PYLINT_BADGE\n$BLACK_BADGE\n$MYPY_BADGE\n$MARKER_END" + + # Replace content between markers using awk + awk -v start="$MARKER_START" -v end="$MARKER_END" -v content="$BADGE_CONTENT" ' + $0 ~ start {print content; skip=1; next} + $0 ~ end {skip=0; next} + !skip + ' "$README_FILE" > "${README_FILE}.tmp" + + mv "${README_FILE}.tmp" "$README_FILE" + echo "::notice file=action.yml,line=438::README updated successfully" + else + echo "::notice file=action.yml,line=440::Badge markers not found in README. Adding badges after title." + + # Insert badges after the first title (# heading) + BADGE_SECTION="\n$MARKER_START\n$PYLINT_BADGE\n$BLACK_BADGE\n$MYPY_BADGE\n$MARKER_END\n" + + # Use awk to insert after first # heading + awk -v section="$BADGE_SECTION" ' + !inserted && /^# / {print; print section; inserted=1; next} + {print} + ' "$README_FILE" > "${README_FILE}.tmp" + + mv "${README_FILE}.tmp" "$README_FILE" + echo "::notice file=action.yml,line=452::Badges added to README successfully" + fi + shell: bash + continue-on-error: true + - name: Commit Badges To Repository id: commit-badges if: steps.generate-badges.outcome == 'success' @@ -398,6 +487,12 @@ runs: git add "${{ inputs.badge-directory }}/pylint.svg" && echo "::notice file=action.yml,line=267::Adding pylint badge to commit." || { echo "::warning file=action.yml,line=268::Failed to add pylint badge."; } git add "${{ inputs.badge-directory }}/black.svg" && echo "::notice file=action.yml,line=270::Adding black badge to commit." || { echo "::warning file=action.yml,line=271::Failed to add black badge."; } git add "${{ inputs.badge-directory }}/mypy.svg" && echo "::notice file=action.yml,line=273::Adding mypy badge to commit." || { echo "::warning file=action.yml,line=274::Failed to add mypy badge."; } + + # Add README if it was updated + if [ "${{ inputs.update-readme }}" == "true" ] && [ "${{ steps.update-readme.outcome }}" == "success" ]; then + git add "${{ inputs.readme-path }}" && echo "::notice file=action.yml,line=276::Adding README to commit." || { echo "::warning file=action.yml,line=277::Failed to add README."; } + fi + git commit -m "Update linting badges [skip ci]" && echo "::notice file=action.yml,line=302::Committing changes to repository." || { echo "::warning file=action.yml,line=303::No changes to commit."; exit 0; } # Push changes to repository From 0f2d84369aa8a9715c54de772eb3d0bd5943f493 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 06:07:09 +0000 Subject: [PATCH 3/4] Update release workflow to support specific version numbers Co-authored-by: thoughtparametersllc <194255310+thoughtparametersllc@users.noreply.github.com> --- .github/workflows/release.yml | 42 +++++++++++++++++++++-------------- CHANGELOG.md | 2 ++ README.md | 14 ++++++++++++ 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4c532a7..1cafb30 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -120,23 +120,31 @@ jobs: echo "Bump type: $BUMP_TYPE" - # Apply version bump - case "$BUMP_TYPE" in - major|MAJOR) - MAJOR=$((MAJOR + 1)) - MINOR=0 - PATCH=0 - ;; - minor|MINOR) - MINOR=$((MINOR + 1)) - PATCH=0 - ;; - patch|PATCH|*) - PATCH=$((PATCH + 1)) - ;; - esac - - NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}" + # Check if BUMP_TYPE is a specific version (e.g., 1.0.0 or v1.0.0) + if [[ "$BUMP_TYPE" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + # Strip 'v' prefix if present + BUMP_TYPE="${BUMP_TYPE#v}" + echo "Using specific version: $BUMP_TYPE" + NEW_VERSION="v${BUMP_TYPE}" + else + # Apply semantic version bump + case "$BUMP_TYPE" in + major|MAJOR) + MAJOR=$((MAJOR + 1)) + MINOR=0 + PATCH=0 + ;; + minor|MINOR) + MINOR=$((MINOR + 1)) + PATCH=0 + ;; + patch|PATCH|*) + PATCH=$((PATCH + 1)) + ;; + esac + + NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}" + fi echo "Previous version: $LATEST_TAG" echo "New version: $NEW_VERSION" diff --git a/CHANGELOG.md b/CHANGELOG.md index d806586..15d349c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,11 +64,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `badge-style` input to choose between relative paths or GitHub URLs (default: path) - Automatic README update functionality with marker support - Badge markers for controlled placement in README files +- Support for specific version numbers in release workflow (e.g., 1.0.0 or v1.0.0) ### Changed - Badge generation is now opt-in via `generate-badges` input instead of always running - README updates are now opt-in via `update-readme` input - Improved badge generation logic with better error handling +- Enhanced release workflow to accept explicit version numbers in addition to major/minor/patch ### Fixed - Aligned action.yml inputs with documented features in README.md diff --git a/README.md b/README.md index 069aa06..625cb62 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,20 @@ This repository includes comprehensive GitHub workflows for CI/CD: For detailed workflow documentation, see [.github/WORKFLOWS.md](.github/WORKFLOWS.md). +### Releasing + +The release workflow supports both automatic semantic versioning and manual version specification: + +**Automatic Release** (when changes are merged to main): +- Automatically detects version bump from CHANGELOG.md +- Creates release with extracted changelog notes +- Updates major version tag (e.g., v1) + +**Manual Release** (for specific versions): +1. Go to Actions → Release and Marketplace → Run workflow +2. Enter version as `1.0.0` or `v1.0.0` (for specific version) or `major`/`minor`/`patch` (for semantic bump) +3. The workflow will create the release and update tags + ### Contributing 1. Fork the repository From f6d8bb5d02608109daa587aa73789a33713f06ff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 06:17:55 +0000 Subject: [PATCH 4/4] Revert addition of badge-related inputs per user request Co-authored-by: thoughtparametersllc <194255310+thoughtparametersllc@users.noreply.github.com> --- CHANGELOG.md | 30 +++++----------- README.md | 19 +--------- action.yml | 97 +--------------------------------------------------- 3 files changed, 11 insertions(+), 135 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15d349c..09b7ba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,27 +57,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -### Added -- `generate-badges` input to control badge generation (default: false) -- `update-readme` input to automatically update README with badges (default: false) -- `readme-path` input to specify README file location (default: README.md) -- `badge-style` input to choose between relative paths or GitHub URLs (default: path) -- Automatic README update functionality with marker support -- Badge markers for controlled placement in README files -- Support for specific version numbers in release workflow (e.g., 1.0.0 or v1.0.0) - -### Changed -- Badge generation is now opt-in via `generate-badges` input instead of always running -- README updates are now opt-in via `update-readme` input -- Improved badge generation logic with better error handling -- Enhanced release workflow to accept explicit version numbers in addition to major/minor/patch - -### Fixed -- Aligned action.yml inputs with documented features in README.md -- Corrected CHANGELOG.md version history - -## [0.0.25] - 2025-11-19 - ### Added - Comprehensive GitHub workflows for CI/CD - Workflow to test all GitHub Action features @@ -86,7 +65,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Changelog validation in release process - Security audit workflow with Dependabot - Lint and test workflow for PRs and pushes +- Support for specific version numbers in release workflow (e.g., 1.0.0 or v1.0.0) + +### Changed +- Enhanced release workflow to accept explicit version numbers in addition to major/minor/patch + +## [1.0.0] - Previous Release + +### Added - Initial Python linting action with Pylint, Black, and MyPy support +- Badge generation and automatic README updates - Flexible Python version support - Custom requirements file support - Comprehensive linting with detailed reporting diff --git a/README.md b/README.md index 625cb62..979d317 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,6 @@ GitHub Action to perform Python linting with Black, Pylint, and MyPy. ### Basic Example -The basic usage runs Pylint, Black, and MyPy on your code. Badge generation is disabled by default. - ```yaml - name: Python Linting uses: thoughtparametersllc/python-linting@v1 @@ -59,22 +57,7 @@ When `generate-badges` is enabled, SVG badges will be automatically generated an When `update-readme` is enabled, the action will automatically insert badge references into your README.md: - Badges are inserted after the title with special markers - You can customize the README path and badge style (relative paths or GitHub URLs) -- The action preserves existing content and only updates the badge section -- **Important**: Your workflow needs write permissions for contents to commit badges: - ```yaml - permissions: - contents: write - ``` - -**Badge Markers** (optional - for controlled placement): - -You can add these markers to your README.md to control where badges are inserted: -```markdown - - -``` - -If markers are not present, badges will be automatically inserted after the first heading. +- The script preserves existing content and only updates the badge section **Manual Badge References** (if not using `update-readme`): diff --git a/action.yml b/action.yml index b769b80..e094455 100644 --- a/action.yml +++ b/action.yml @@ -34,26 +34,6 @@ inputs: required: false default: '.github/badges' - generate-badges: - description: Generate and commit SVG badges to the repository. Defaults to false. - required: false - default: 'false' - - update-readme: - description: Automatically update README.md with badge references. Defaults to false. - required: false - default: 'false' - - readme-path: - description: Path to README.md file to update with badges. Defaults to README.md. - required: false - default: 'README.md' - - badge-style: - description: Badge style - 'url' for GitHub URLs or 'path' for relative paths. Defaults to path. - required: false - default: 'path' - runs: using: composite steps: @@ -325,7 +305,7 @@ runs: - name: Generate SVG Badges id: generate-badges - if: steps.install-linting-tools.outcome == 'success' && inputs.generate-badges == 'true' && always() + if: steps.install-linting-tools.outcome == 'success' && always() run: | if [ test -d "${{ inputs.badge-directory }}" ]; then echo "::notice file=action.yml,line=170::Badge directory exists: ${{ inputs.badge-directory }}" @@ -400,75 +380,6 @@ runs: shell: bash continue-on-error: true - - name: Update README with Badges - id: update-readme - if: steps.generate-badges.outcome == 'success' && inputs.update-readme == 'true' - run: | - README_FILE="${{ inputs.readme-path }}" - BADGE_DIR="${{ inputs.badge-directory }}" - BADGE_STYLE="${{ inputs.badge-style }}" - - echo "::notice file=action.yml,line=398::Updating README with badge references" - - # Check if README exists - if [ ! -f "$README_FILE" ]; then - echo "::warning file=action.yml,line=402::README file not found: $README_FILE" - exit 0 - fi - - # Define badge markers - MARKER_START="" - MARKER_END="" - - # Generate badge references based on style - if [ "$BADGE_STYLE" == "url" ]; then - # Use GitHub raw URLs - REPO="${{ github.repository }}" - BRANCH="${{ github.ref_name }}" - PYLINT_BADGE="![Pylint](https://raw.githubusercontent.com/$REPO/$BRANCH/$BADGE_DIR/pylint.svg)" - BLACK_BADGE="![Black](https://raw.githubusercontent.com/$REPO/$BRANCH/$BADGE_DIR/black.svg)" - MYPY_BADGE="![MyPy](https://raw.githubusercontent.com/$REPO/$BRANCH/$BADGE_DIR/mypy.svg)" - else - # Use relative paths - PYLINT_BADGE="![Pylint]($BADGE_DIR/pylint.svg)" - BLACK_BADGE="![Black]($BADGE_DIR/black.svg)" - MYPY_BADGE="![MyPy]($BADGE_DIR/mypy.svg)" - fi - - # Check if markers exist - if grep -q "$MARKER_START" "$README_FILE" && grep -q "$MARKER_END" "$README_FILE"; then - echo "::notice file=action.yml,line=426::Updating existing badge section in README" - - # Create badge content - BADGE_CONTENT="$MARKER_START\n$PYLINT_BADGE\n$BLACK_BADGE\n$MYPY_BADGE\n$MARKER_END" - - # Replace content between markers using awk - awk -v start="$MARKER_START" -v end="$MARKER_END" -v content="$BADGE_CONTENT" ' - $0 ~ start {print content; skip=1; next} - $0 ~ end {skip=0; next} - !skip - ' "$README_FILE" > "${README_FILE}.tmp" - - mv "${README_FILE}.tmp" "$README_FILE" - echo "::notice file=action.yml,line=438::README updated successfully" - else - echo "::notice file=action.yml,line=440::Badge markers not found in README. Adding badges after title." - - # Insert badges after the first title (# heading) - BADGE_SECTION="\n$MARKER_START\n$PYLINT_BADGE\n$BLACK_BADGE\n$MYPY_BADGE\n$MARKER_END\n" - - # Use awk to insert after first # heading - awk -v section="$BADGE_SECTION" ' - !inserted && /^# / {print; print section; inserted=1; next} - {print} - ' "$README_FILE" > "${README_FILE}.tmp" - - mv "${README_FILE}.tmp" "$README_FILE" - echo "::notice file=action.yml,line=452::Badges added to README successfully" - fi - shell: bash - continue-on-error: true - - name: Commit Badges To Repository id: commit-badges if: steps.generate-badges.outcome == 'success' @@ -487,12 +398,6 @@ runs: git add "${{ inputs.badge-directory }}/pylint.svg" && echo "::notice file=action.yml,line=267::Adding pylint badge to commit." || { echo "::warning file=action.yml,line=268::Failed to add pylint badge."; } git add "${{ inputs.badge-directory }}/black.svg" && echo "::notice file=action.yml,line=270::Adding black badge to commit." || { echo "::warning file=action.yml,line=271::Failed to add black badge."; } git add "${{ inputs.badge-directory }}/mypy.svg" && echo "::notice file=action.yml,line=273::Adding mypy badge to commit." || { echo "::warning file=action.yml,line=274::Failed to add mypy badge."; } - - # Add README if it was updated - if [ "${{ inputs.update-readme }}" == "true" ] && [ "${{ steps.update-readme.outcome }}" == "success" ]; then - git add "${{ inputs.readme-path }}" && echo "::notice file=action.yml,line=276::Adding README to commit." || { echo "::warning file=action.yml,line=277::Failed to add README."; } - fi - git commit -m "Update linting badges [skip ci]" && echo "::notice file=action.yml,line=302::Committing changes to repository." || { echo "::warning file=action.yml,line=303::No changes to commit."; exit 0; } # Push changes to repository