diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml deleted file mode 100644 index 7f0e127..0000000 --- a/.github/workflows/changelog.yml +++ /dev/null @@ -1,142 +0,0 @@ -name: "Generate Changelog" - -# Triggers when pull requests are merged to master -on: - pull_request: - branches: [master] - types: [closed] - -jobs: - generate-changelog: - # Only run if the PR was merged (not just closed) - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 # to fetch all history for all tags and branches - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup .NET - uses: actions/setup-dotnet@v3 - with: - dotnet-version: "8.0.x" - - # https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/setup.md#usage-examples - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v3.2.1 - with: - versionSpec: '6.3.x' - - # https://github.com/GitTools/actions/blob/main/docs/examples/github/gitversion/execute/usage-examples.md - - name: Use GitVersion - id: gitversion - uses: gittools/actions/gitversion/execute@v3.2.1 - - - name: Display GitVersion outputs - run: | - echo "Version: ${{ steps.gitversion.outputs.semVer }}" - echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.commitsSinceVersionSource }}" - echo "PreReleaseTag: ${{ steps.gitversion.outputs.preReleaseTagWithDash }}" - - - name: Generate Changelog - if: steps.gitversion.outputs.commitsSinceVersionSource > 0 - id: generate_changelog - uses: mikepenz/release-changelog-builder-action@v4 - with: - configuration: ".github/changelog-configuration.json" - toTag: ${{ steps.gitversion.outputs.semVer }} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Update CHANGELOG.md - if: steps.gitversion.outputs.commitsSinceVersionSource > 0 - run: | - # Get current date - CURRENT_DATE=$(date +"%Y-%m-%d") - VERSION="${{ steps.gitversion.outputs.semVer }}" - - echo "Updating CHANGELOG.md for version $VERSION..." - - # Create temporary file with new changelog entry - cat > temp_changelog.md << 'EOF' - # Changelog - - All notable changes to this project will be documented in this file. - - The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - - ## [Unreleased] - - EOF - - # Add the new version section - echo "" >> temp_changelog.md - echo "## [$VERSION] - $CURRENT_DATE" >> temp_changelog.md - echo "" >> temp_changelog.md - echo "${{ steps.generate_changelog.outputs.changelog }}" >> temp_changelog.md - echo "" >> temp_changelog.md - - # Append existing changelog content (skip the header and unreleased section) - if [ -f CHANGELOG.md ]; then - # Extract everything after the [Unreleased] section until the end, but before the links - awk ' - BEGIN { in_unreleased=0; in_links=0 } - /^## \[Unreleased\]/ { in_unreleased=1; next } - /^## \[/ && in_unreleased { in_unreleased=0; print; next } - /^\[.*\]: https:/ { in_links=1 } - !in_unreleased && !in_links { print } - ' CHANGELOG.md >> temp_changelog.md - fi - - # Add the version links at the end - echo "" >> temp_changelog.md - - # Get the previous version for comparison link - PREV_VERSION=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo "") - - if [ -n "$PREV_VERSION" ] && [ "$PREV_VERSION" != "$VERSION" ]; then - echo "[Unreleased]: https://github.com/kdcllc/Bet.CodeAnalyzers/compare/v$VERSION...HEAD" >> temp_changelog.md - echo "[$VERSION]: https://github.com/kdcllc/Bet.CodeAnalyzers/compare/v$PREV_VERSION...v$VERSION" >> temp_changelog.md - else - echo "[Unreleased]: https://github.com/kdcllc/Bet.CodeAnalyzers/compare/v$VERSION...HEAD" >> temp_changelog.md - echo "[$VERSION]: https://github.com/kdcllc/Bet.CodeAnalyzers/releases/tag/v$VERSION" >> temp_changelog.md - fi - - # Add any existing version links (excluding the ones we just added) - if [ -f CHANGELOG.md ]; then - grep '^\[.*\]: https:' CHANGELOG.md | grep -v "\[Unreleased\]:" | grep -v "\[$VERSION\]:" >> temp_changelog.md || true - fi - - # Replace the original file - mv temp_changelog.md CHANGELOG.md - - - name: Commit updated CHANGELOG.md - if: steps.gitversion.outputs.commitsSinceVersionSource > 0 - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add CHANGELOG.md - - # Check if there are changes to commit - if git diff --staged --quiet; then - echo "No changes to CHANGELOG.md" - else - git commit -m "CHORE: Update CHANGELOG.md for version ${{ steps.gitversion.outputs.semVer }}" - git push - echo "CHANGELOG.md updated and pushed" - fi - - - name: Create GitHub Release - if: steps.gitversion.outputs.commitsSinceVersionSource > 0 - uses: actions/create-release@v1.1.4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ steps.gitversion.outputs.semVer }} - release_name: Release v${{ steps.gitversion.outputs.semVer }} - body: ${{ steps.generate_changelog.outputs.changelog }} - draft: false - prerelease: false \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 87af231..9f31715 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -74,7 +74,6 @@ jobs: - name: Publish Nuget Packages run: dotnet nuget push packages/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate -n - #This workflow contains tag: runs-on: ubuntu-latest needs: [build] @@ -83,3 +82,13 @@ jobs: run: | echo "Version: ${{ needs.build.outputs.Version }}" echo "CommitsSinceVersionSource: ${{ needs.build.outputs.CommitsSinceVersionSource }}" + + - name: Create Tag and Release + id: create_release + uses: actions/create-release@v1.1.1 + if: needs.build.outputs.CommitsSinceVersionSource > 0 # only create a release if there has been a commit + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # this token is provided by actions not need to create + with: + tag_name: ${{ needs.build.outputs.Version }} + release_name: Release ${{ needs.build.outputs.Version }} diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 56d782d..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,52 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - - -## [2.0.0-17] - 2025-10-02 - -- No changes - -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [1.0.11] - 2025-10-01 - -### ๐Ÿš€ Features -- Update formatting in README and settings.props -- Update GitHub Actions to latest versions -- Refactor test project structure -- Update README and add Copilot instructions - - -### Added - -- Automated changelog generation from GitHub Actions - -## [2.0.0-preview1] - 2024-XX-XX - -### Features - -- Initial version of Bet.CodeAnalyzers package -- StyleCop and Roslynator analyzer integration -- Bet.EditorConfig package with MSBuild task for installing .editorconfig - -### Changed - -- Updated to target .NET Standard 2.0 -- Improved packaging and development dependency configuration - - -[Unreleased]: https://github.com/kdcllc/Bet.CodeAnalyzers/compare/v2.0.0-17...HEAD -[2.0.0-17]: https://github.com/kdcllc/Bet.CodeAnalyzers/compare/v1.0.12...v2.0.0-17 -[2.0.0-preview1]: https://github.com/kdcllc/Bet.CodeAnalyzers/releases/tag/v2.0.0-preview1 -[1.0.11]: https://github.com/kdcllc/Bet.CodeAnalyzers/compare/1.0.11...v1.0.11 diff --git a/GitVersion.yml b/GitVersion.yml index 588924c..651f590 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,4 +1,5 @@ -mode: ContinuousDelivery +workflow: GitHubFlow/v1 +mode: ContinuousDeployment next-version: 2.0.0 branches: master: @@ -9,9 +10,10 @@ branches: mode: ContinuousDelivery label: useBranchName regex: ^features?[/-] - dev: + develop: mode: ContinuousDelivery - regex: ^dev$ + label: preview + regex: ^dev(elop)?(ment)?$ ignore: sha: [] merge-message-formats: {} diff --git a/README.md b/README.md index e1e23b2..4458587 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,3 @@ Best practices: ## References - [Shipping a cross-platform MSBuild task in a NuGet package](https://natemcmaster.com/blog/2017/07/05/msbuild-task-in-nuget/) - -## Changelog - -See [CHANGELOG.md](CHANGELOG.md) for a detailed history of changes to this project. diff --git a/scripts/generate-changelog.sh b/scripts/generate-changelog.sh deleted file mode 100755 index dea6eea..0000000 --- a/scripts/generate-changelog.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash - -# Script to manually generate changelog for a specific version -# Usage: ./scripts/generate-changelog.sh [version] [from-tag] - -set -e - -VERSION=${1:-""} -FROM_TAG=${2:-""} - -if [ -z "$VERSION" ]; then - echo "Usage: $0 [from-tag]" - echo "Example: ./scripts/generate-changelog.sh 2.1.0 v2.0.0" - exit 1 -fi - -echo "Generating changelog for version $VERSION..." - -# Get current date -CURRENT_DATE=$(date +"%Y-%m-%d") - -# Check if we have gh CLI installed -if ! command -v gh &> /dev/null; then - echo "GitHub CLI (gh) is required but not installed." - echo "Please install it from: https://cli.github.com/" - exit 1 -fi - -# Generate changelog using GitHub CLI -echo "Fetching commits and pull requests..." - -if [ -n "$FROM_TAG" ]; then - RANGE="${FROM_TAG}..HEAD" -else - # Get the latest tag - LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") - if [ -n "$LATEST_TAG" ]; then - RANGE="${LATEST_TAG}..HEAD" - else - RANGE="HEAD" - fi -fi - -echo "Using range: $RANGE" - -# Create temporary changelog entry -cat > temp_changelog_entry.md << EOF -## [$VERSION] - $CURRENT_DATE - -EOF - -# Get commits in the range and categorize them -echo "### ๐Ÿ’ฅ Breaking Changes" >> temp_changelog_entry.md -git log --oneline $RANGE | grep -i "BREAKING CHANGE:" | sed 's/^[a-f0-9]* BREAKING CHANGE: /- /' >> temp_changelog_entry.md || true - -echo "" >> temp_changelog_entry.md -echo "### ๐Ÿš€ Features" >> temp_changelog_entry.md -git log --oneline $RANGE | grep -i "CHANGE:" | grep -v "BREAKING CHANGE:" | sed 's/^[a-f0-9]* CHANGE: /- /' >> temp_changelog_entry.md || true - -echo "" >> temp_changelog_entry.md -echo "### ๐Ÿ› Bug Fixes" >> temp_changelog_entry.md -git log --oneline $RANGE | grep -i "FIX:" | sed 's/^[a-f0-9]* FIX: /- /' >> temp_changelog_entry.md || true - -echo "" >> temp_changelog_entry.md -echo "### ๐Ÿ”’ Security" >> temp_changelog_entry.md -git log --oneline $RANGE | grep -i "SECURITY:" | sed 's/^[a-f0-9]* SECURITY: /- /' >> temp_changelog_entry.md || true - -echo "" >> temp_changelog_entry.md -echo "### ๐Ÿงช Tests" >> temp_changelog_entry.md -git log --oneline $RANGE | grep -i "TESTS:" | sed 's/^[a-f0-9]* TESTS: /- /' >> temp_changelog_entry.md || true - -echo "" >> temp_changelog_entry.md -echo "### ๐Ÿ”ง Maintenance" >> temp_changelog_entry.md -git log --oneline $RANGE | grep -i "CHORE:" | sed 's/^[a-f0-9]* CHORE: /- /' >> temp_changelog_entry.md || true - -echo "" >> temp_changelog_entry.md - -# Remove empty sections -sed -i '/^### .*/,/^$/{/^### .*/{N;/\n$/d;}}' temp_changelog_entry.md - -# Create new changelog -echo "Updating CHANGELOG.md..." - -# Create backup -cp CHANGELOG.md CHANGELOG.md.bak - -# Create new changelog with the new entry inserted after [Unreleased] -awk ' -/^## \[Unreleased\]/ { - print $0 - print "" - while ((getline line < "temp_changelog_entry.md") > 0) { - print line - } - close("temp_changelog_entry.md") - next -} -{ print } -' CHANGELOG.md.bak > CHANGELOG.md - -# Update the links at the bottom -if [ -n "$FROM_TAG" ]; then - # Update the [Unreleased] link to point to the new version - sed -i "s|\[Unreleased\]: https://github.com/kdcllc/Bet.CodeAnalyzers/compare/.*\.\.\.HEAD|[Unreleased]: https://github.com/kdcllc/Bet.CodeAnalyzers/compare/v$VERSION...HEAD|" CHANGELOG.md - - # Add the new version link - echo "[$VERSION]: https://github.com/kdcllc/Bet.CodeAnalyzers/compare/$FROM_TAG...v$VERSION" >> CHANGELOG.md -fi - -# Clean up -rm temp_changelog_entry.md - -echo "Changelog updated successfully!" -echo "Please review CHANGELOG.md and commit the changes." \ No newline at end of file