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
42 changes: 25 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Release and Marketplace

Check warning on line 1 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

1:1 [document-start] missing document start "---"

Check warning on line 1 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

1:1 [document-start] missing document start "---"

# This workflow handles automatic semantic versioning, tagging, and GitHub Marketplace submission
# It runs when changes are pushed to main and creates releases based on changelog entries

on:

Check warning on line 6 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

6:1 [truthy] truthy value should be one of [false, true]

Check warning on line 6 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

6:1 [truthy] truthy value should be one of [false, true]
push:
branches: [ main ]

Check failure on line 8 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

8:21 [brackets] too many spaces inside brackets

Check failure on line 8 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

8:16 [brackets] too many spaces inside brackets

Check failure on line 8 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

8:21 [brackets] too many spaces inside brackets

Check failure on line 8 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

8:16 [brackets] too many spaces inside brackets
workflow_dispatch:
inputs:
version:
Expand Down Expand Up @@ -33,7 +33,7 @@
run: |
if grep -q "## \[Unreleased\]" CHANGELOG.md; then
# Check if there's actual content under Unreleased
if grep -A 20 "## \[Unreleased\]" CHANGELOG.md | grep -qE "^### (Added|Changed|Deprecated|Removed|Fixed|Security)"; then

Check failure on line 36 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

36:121 [line-length] line too long (132 > 120 characters)

Check failure on line 36 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

36:121 [line-length] line too long (132 > 120 characters)
echo "has_unreleased=true" >> $GITHUB_OUTPUT
echo "✓ Found unreleased changes in CHANGELOG.md"
else
Expand All @@ -51,7 +51,7 @@
run: |
# Extract content between [Unreleased] and the next version heading
NOTES=$(awk '/## \[Unreleased\]/,/^## \[/' CHANGELOG.md | sed '1d;$d' | sed '/^$/d')

Check failure on line 54 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

54:1 [trailing-spaces] trailing spaces

Check failure on line 54 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / Lint YAML Files

54:1 [trailing-spaces] trailing spaces
# Save to output (handle multiline)
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
echo "$NOTES" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -120,23 +120,31 @@

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
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a specific version is provided, there's no validation to prevent version downgrades or duplicate versions. Consider adding a check to ensure the specified version is greater than the latest tag and doesn't already exist:

# After line 128, add validation
if git tag -l "$NEW_VERSION" | grep -q "$NEW_VERSION"; then
  echo "Error: Version $NEW_VERSION already exists as a tag"
  exit 1
fi

# Also verify version is greater than current
if [[ "$NEW_VERSION" < "$LATEST_TAG" ]]; then
  echo "Error: Version $NEW_VERSION is less than current version $LATEST_TAG"
  exit 1
fi
Suggested change
else
# Validation: prevent duplicate tags and version downgrades
if git tag -l "$NEW_VERSION" | grep -q "$NEW_VERSION"; then
echo "Error: Version $NEW_VERSION already exists as a tag"
exit 1
fi
# Compare versions (strip 'v' prefix)
if [ "$(printf '%s\n' "${BUMP_TYPE}" "${CURRENT_VERSION}" | sort -V | tail -n1)" != "${BUMP_TYPE}" ]; then
echo "Error: Version $NEW_VERSION is not greater than current version v${CURRENT_VERSION}"
exit 1
fi

Copilot uses AI. Check for mistakes.
# 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"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ 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

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,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
Expand Down
Loading