diff --git a/.github/VERSION-DETECTION.md b/.github/VERSION-DETECTION.md new file mode 100644 index 0000000..135b2ce --- /dev/null +++ b/.github/VERSION-DETECTION.md @@ -0,0 +1,70 @@ +# Version Detection Test Examples + +This file demonstrates how the automated version detection works with different branch merges and commit patterns. + +## Branch-Based Version Detection + +### ✅ Minor Version Bump (v0.10.2 → v0.11.0) +**Trigger**: Merging from `feat*` branches + +```bash +# Developer workflow: +git checkout master +git checkout -b feat/new-user-authentication +git commit -m "add OAuth login support" +git commit -m "add user profile management" +git push origin feat/new-user-authentication + +# Create PR and merge to master +# Result: Automatic minor version bump v0.10.2 → v0.11.0 +``` + +### ✅ Patch Version Bump (v0.10.2 → v0.10.3) +**Trigger**: Merging from any other branch + +```bash +# Bug fix: +git checkout -b fix/login-timeout +git commit -m "fix: resolve session timeout issue" +# Result: v0.10.2 → v0.10.3 + +# Documentation: +git checkout -b docs/update-api-guide +git commit -m "docs: update API documentation" +# Result: v0.10.2 → v0.10.3 + +# Refactoring: +git checkout -b refactor/cleanup-auth +git commit -m "refactor: simplify authentication flow" +# Result: v0.10.2 → v0.10.3 +``` + +## Detection Priority + +The system checks in this order: + +1. **Feature branches** (highest priority) + - Checks merged branch names for `feat*` pattern + - Also checks commit messages for `feat:` prefix + - Results in minor version bump (Y) + +2. **Everything else** (default) + - All other branch merges and commits + - Results in patch version bump (Z) + +## Example Scenarios + +| Branch Name | Commit Message | Version Change | Reason | +|-------------|----------------|----------------|---------| +| `feat/auth` | "add login system" | v0.10.2 → v0.11.0 | feat branch (minor) | +| `fix/bug` | "fix: resolve crash" | v0.10.2 → v0.10.3 | non-feat branch (patch) | +| `docs/readme` | "docs: update guide" | v0.10.2 → v0.10.3 | non-feat branch (patch) | +| `fix/bug` | "feat: add new feature" | v0.10.2 → v0.11.0 | feat in commit (minor) | +| `refactor/code` | "refactor: improve structure" | v0.10.2 → v0.10.3 | non-feat branch (patch) | + +This ensures that: +- ✅ New features always increment minor version (Y number) +- ✅ Bug fixes and other changes increment patch version (Z number) +- ✅ Major version (X) is only incremented manually +- ✅ Documentation and dependency updates don't trigger releases +- ✅ No manual version management needed diff --git a/.github/WORKFLOWS.md b/.github/WORKFLOWS.md index a09d3fe..fbf6070 100644 --- a/.github/WORKFLOWS.md +++ b/.github/WORKFLOWS.md @@ -1,7 +1,15 @@ # GitHub Actions Workflows Documentation -This repository uses a comprehensive GitHub Actions setup with different workflows for different purposes. +This repository uses: Fully automated release creation with zero manual intervention +- ✅ Detects when releases are needed (new commits to master, excluding docs/deps) +- ✅ Analyzes commit messages for semantic versioning +- ✅ Calculates next version automatically (major/minor) +- ✅ Creates release branches with version updates using own action +- ✅ Relies on PUSH-OTHER.yml for PR creation +- ✅ Supports manual triggering for custom releases +- ✅ Skips releases for documentation and dependency updates +This repository uses a comprehensive GitHub Actions setup with different workflows for different purposes. ## Workflow Overview ### 1. PUSH-MASTER.yml @@ -24,38 +32,69 @@ This repository uses a comprehensive GitHub Actions setup with different workflo - ✅ Update repository labels (dry run) - ✅ Run Hadolint linting on Dockerfile - ✅ Build Docker image (test only for regular branches) -- ✅ Build & push test Docker images for `test/*` branches +- ✅ Build & push test Docker images for `test*` branches - ✅ Create Pull Requests based on branch naming conventions **Special handling for test branches**: -- Branches starting with `test/` → Build and push Docker images with `test-` prefix +- Branches starting with `test` → Build and push Docker images with `test-` prefix - Other branches → Build test only (no push) **Branch naming conventions for auto-PR creation**: -- `bug/*` → Creates PR with "bugfix" label -- `dep/*` → Creates PR with "dependency" label -- `doc/*` → Creates PR with "documentation" label -- `feat/*` → Creates PR with "feature" label -- `test/*` → Creates draft PR with "test" label + pushes test Docker images +- `bug*` → Creates PR with "bugfix" label +- `dep*` → Creates PR with "dependency" label +- `doc*` → Creates PR with "documentation" label +- `feat*` → Creates PR with "feature" label +- `test*` → Creates draft PR with "test" label + pushes test Docker images - Other branches → Creates PR with "feature" label ### 3. RELEASE.yml -**Trigger**: GitHub release published - -**Purpose**: Production deployment -- ✅ Build multi-architecture Docker images (amd64, arm64) -- ✅ Push images to Docker Hub with release version tag +**Trigger**: +- Push to `release/vX.Y.Z` branches (creates release PR) +- Pull request merge from `release/vX.Y.Z` branches to master (publishes release) + +**Purpose**: Handle release branch workflows and Docker image publishing +- ✅ Create release PRs with version updates when pushing to `release/vX.Y.Z` branches +- ✅ Build multi-architecture Docker images (amd64, arm64) when release PRs are merged +- ✅ Push images to Docker Hub with release version tag and `latest` - ✅ Push images to GitHub Container Registry +- ✅ Create GitHub release with version tag - ✅ Update Docker Hub description -- ✅ Update `action.yml` with new image version - -**Release Process**: -1. Create GitHub release with version tag (e.g., `v0.11.0`) -2. Workflow automatically builds and pushes Docker images -3. Images are tagged with the release version -4. `action.yml` is updated to reference the new version - -### 4. CRON.yml +- ✅ Clean up release branch after merge + +### 4. AUTO-VERSION.yml +**Trigger**: +- Push to `master` branch (automatic) +- Manual workflow dispatch (optional) + +**Purpose**: Fully automated release creation with zero manual intervention +- ✅ Detects when releases are needed (new commits to master) +- ✅ Analyzes commit messages for semantic versioning +- ✅ Calculates next version automatically (major/minor/patch) +- ✅ Creates release branches with version updates +- ✅ Opens detailed release PRs +- ✅ Supports manual triggering for custom releases + +**Automated Release Process**: +1. New commits pushed to master (excluding docs/dependencies) +2. System analyzes merged branch names and commit messages: + - Merged from "feat" branches → minor version (v0.10.2 → v0.11.0) + - Other changes → patch version (v0.10.2 → v0.10.3) +3. Automatically creates `release/vX.Y.Z` branch using own action +4. Updates version in `action.yml` and `Makefile` +5. PUSH-OTHER.yml workflow creates PR automatically +6. When merged → triggers RELEASE.yml workflow for publishing + +### 5. AUTO-RELEASE.yml +**Trigger**: Manual workflow dispatch only + +**Purpose**: Manual release creation with version input +- ✅ Allows manual specification of release version +- ✅ Supports minor/major release types +- ✅ Creates release branches using own action +- ✅ Relies on PUSH-OTHER.yml for PR creation +- ✅ Validates version format and availability + +### 6. CRON.yml **Trigger**: Weekly schedule (Sundays at 5:00 AM UTC) **Purpose**: Weekly health check and test image refresh @@ -85,13 +124,23 @@ This repository uses a comprehensive GitHub Actions setup with different workflo ### Development Flow 1. Create feature branch with appropriate naming convention 2. Push changes → Triggers build test and auto-PR creation -3. Review and merge PR to master → Triggers master build test -4. Create GitHub release → Triggers production deployment +3. Review and merge PR to master → Triggers automatic release detection +4. System automatically creates release (if new commits warrant it) +5. Review and merge release PR → Triggers production deployment ### Production Deployment -- Only happens on GitHub releases -- Ensures only tested, reviewed code reaches production -- Automatic versioning and tagging -- Docker Hub and GitHub Container Registry deployment - -This setup ensures a safe, automated, and well-tested deployment pipeline while maintaining development velocity. +- **Fully automated**: No manual release creation needed +- **Smart detection**: Only releases when there are actual changes +- **Semantic versioning**: Automatic version calculation from commit messages +- **Safe process**: Release PRs provide review opportunity before publishing +- **GitHub release creation**: Automated with release notes +- **Docker Hub and GitHub Container Registry**: Automatic multi-architecture deployment + +### Release Automation Strategy +- **Zero manual work**: Push to master → automatic release detection → release PR → merge → publish +- **Semantic commits**: Commit message analysis determines version type +- **Branch protection**: All releases go through PR review process +- **Failsafe mechanisms**: Version validation, duplicate prevention, format checking +- **Clean automation**: Automatic branch cleanup and proper tagging + +This setup provides **complete automation** while maintaining safety through the PR review process. No manual release management required! diff --git a/.github/workflows/AUTO-RELEASE.yml b/.github/workflows/AUTO-RELEASE.yml new file mode 100644 index 0000000..c311677 --- /dev/null +++ b/.github/workflows/AUTO-RELEASE.yml @@ -0,0 +1,97 @@ +name: Automated Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version (e.g., v0.12.0)' + required: true + type: string + release_type: + description: 'Type of release' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + +jobs: + create_automated_release: + name: Create Automated Release + runs-on: ubuntu-24.04-arm + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Validate version format + run: | + VERSION="${{ github.event.inputs.version }}" + if [[ ! $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "❌ Invalid version format. Use format: v1.2.3" + exit 1 + fi + echo "✅ Version format is valid: $VERSION" + + - name: Check if version already exists + run: | + VERSION="${{ github.event.inputs.version }}" + if git tag -l | grep -q "^${VERSION}$"; then + echo "❌ Version $VERSION already exists" + exit 1 + fi + echo "✅ Version $VERSION is available" + + - name: Get current date + id: date + run: echo "date=$(date +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT + + - name: Update version in action.yml + run: | + VERSION="${{ github.event.inputs.version }}" + sed -i "s|image: docker://devopsinfra/action-commit-push:.*|image: docker://devopsinfra/action-commit-push:${VERSION}|" action.yml + echo "✅ Updated action.yml to use version: ${VERSION}" + + - name: Update version in Makefile + run: | + VERSION="${{ github.event.inputs.version }}" + # Update the fallback version in Makefile + sed -i "s|echo \"v[0-9]\+\.[0-9]\+\.[0-9]\+\"|echo \"${VERSION}\"|" Makefile + echo "✅ Updated Makefile fallback version to: ${VERSION}" + + - name: Create release branch and commit changes + uses: devops-infra/action-commit-push@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + target_branch: release/${{ github.event.inputs.version }} + commit_message: | + Automated Release ${{ github.event.inputs.version }} + + This is an **automated release** created via workflow dispatch. + + Release Details + - **Version**: `${{ github.event.inputs.version }}` + - **Type**: `${{ github.event.inputs.release_type }}` + - **Triggered by**: @${{ github.actor }} + - **Date**: ${{ steps.date.outputs.date }} + + Changes in this release + - ✅ Updated `action.yml` to reference Docker image `${{ github.event.inputs.version }}` + - ✅ Updated `Makefile` fallback version to `${{ github.event.inputs.version }}` + + What happens when this PR is merged? + 1. 🐳 Docker images will be built and pushed to Docker Hub and GitHub Packages + 2. 🏷️ A GitHub release will be created with tag `${{ github.event.inputs.version }}` + 3. 📝 Docker Hub description will be updated + 4. 🧹 Release branch will be cleaned up automatically + + Auto-merge Information + This PR can be safely merged as it only contains version updates. + + **⚠️ Important:** Once merged, this will immediately publish Docker images to production registries. + + --- + *This release was created automatically. No manual intervention required.* diff --git a/.github/workflows/AUTO-VERSION.yml b/.github/workflows/AUTO-VERSION.yml new file mode 100644 index 0000000..9171464 --- /dev/null +++ b/.github/workflows/AUTO-VERSION.yml @@ -0,0 +1,187 @@ +name: Auto-Version Release + +on: + push: + branches: + - master + paths-ignore: + - 'README.md' + - '.github/WORKFLOWS.md' + - '.github/VERSION-DETECTION.md' + - 'LICENSE' + - '*.md' + workflow_dispatch: + inputs: + release_type: + description: 'Type of release (auto-detects from commits if not specified)' + required: false + default: 'auto' + type: choice + options: + - auto + - patch + - minor + - major + +jobs: + check_for_release: + name: Check if Release Needed + runs-on: ubuntu-24.04-arm + outputs: + should_release: ${{ steps.check.outputs.should_release }} + version_type: ${{ steps.check.outputs.version_type }} + new_version: ${{ steps.check.outputs.new_version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for release triggers + id: check + run: | + # Get the latest tag + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + echo "Latest tag: $LATEST_TAG" + + # Get commits since last tag + COMMITS_SINCE_TAG=$(git rev-list ${LATEST_TAG}..HEAD --count) + echo "Commits since last tag: $COMMITS_SINCE_TAG" + + # If no new commits, don't release + if [ "$COMMITS_SINCE_TAG" -eq 0 ]; then + echo "No new commits since last tag" + echo "should_release=false" >> $GITHUB_OUTPUT + exit 0 + fi + + # Get branch names that were merged since last tag + MERGED_BRANCHES=$(git log ${LATEST_TAG}..HEAD --merges --pretty=format:"%s" | grep -o "from [^']*" | sed 's/from //' || echo "") + echo "Merged branches since last tag:" + echo "$MERGED_BRANCHES" + + # Also check commit messages for manual detection + COMMIT_MESSAGES=$(git log ${LATEST_TAG}..HEAD --pretty=format:"%s" --max-count=50) + if [ $? -ne 0 ]; then + echo "Error: Failed to retrieve commit messages for range ${LATEST_TAG}..HEAD" >&2 + exit 1 + fi + echo "Commit messages:" + echo "$COMMIT_MESSAGES" + + # Skip release for dependency and docs updates + if echo "$MERGED_BRANCHES" | grep -iE "^dep|^dependabot|^docs|/dep|/docs"; then + echo "Skipping release for dependency/docs updates" + echo "should_release=false" >> $GITHUB_OUTPUT + exit 0 + fi + + if echo "$COMMIT_MESSAGES" | grep -i "^dep:\|^docs:\|^dependencies:\|^dependency:"; then + echo "Skipping release for dependency/docs commits" + echo "should_release=false" >> $GITHUB_OUTPUT + exit 0 + fi + + # Determine version type + VERSION_TYPE="${{ github.event.inputs.release_type }}" + if [ "$VERSION_TYPE" = "auto" ] || [ -z "$VERSION_TYPE" ]; then + # Check for feat branches first (minor version bump - Y) + if echo "$MERGED_BRANCHES" | grep -iE "^feat|/feat"; then + VERSION_TYPE="minor" + # Check for feat in commit messages as fallback + elif echo "$COMMIT_MESSAGES" | grep -i "^feat\|feat:"; then + VERSION_TYPE="minor" + # Everything else is patch (Z) + else + VERSION_TYPE="patch" + fi + fi + + echo "Detected version type: $VERSION_TYPE" + + # Calculate new version + CURRENT_VERSION=${LATEST_TAG#v} + IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" + MAJOR=${VERSION_PARTS[0]:-0} + MINOR=${VERSION_PARTS[1]:-0} + PATCH=${VERSION_PARTS[2]:-0} + + case $VERSION_TYPE in + major) + NEW_VERSION="v$((MAJOR + 1)).0.0" + ;; + minor) + NEW_VERSION="v${MAJOR}.$((MINOR + 1)).0" + ;; + patch) + NEW_VERSION="v${MAJOR}.${MINOR}.$((PATCH + 1))" + ;; + esac + + echo "New version: $NEW_VERSION" + + # Set outputs + echo "should_release=true" >> $GITHUB_OUTPUT + echo "version_type=$VERSION_TYPE" >> $GITHUB_OUTPUT + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + + create_release: + name: Create Automated Release + needs: check_for_release + if: needs.check_for_release.outputs.should_release == 'true' + runs-on: ubuntu-24.04-arm + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Update version in action.yml + run: | + VERSION="${{ needs.check_for_release.outputs.new_version }}" + sed -i "s|image: docker://devopsinfra/action-commit-push:.*|image: docker://devopsinfra/action-commit-push:${VERSION}|" action.yml + echo "✅ Updated action.yml to use version: ${VERSION}" + + - name: Update version in Makefile + run: | + VERSION="${{ needs.check_for_release.outputs.new_version }}" + sed -i "s|echo \"v[0-9]\+\.[0-9]\+\.[0-9]\+\"|echo \"${VERSION}\"|" Makefile + echo "✅ Updated Makefile fallback version to: ${VERSION}" + + - name: Create release branch and commit changes + uses: devops-infra/action-commit-push@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + target_branch: release/${{ needs.check_for_release.outputs.new_version }} + commit_message: | + 🤖 Fully Automated Release ${{ needs.check_for_release.outputs.new_version }} + + This release was **automatically created** and requires **no manual intervention**. + + 📊 Release Details + - **Version**: `${{ needs.check_for_release.outputs.new_version }}` + - **Type**: `${{ needs.check_for_release.outputs.version_type }}` (auto-detected) + - **Trigger**: `${{ github.event_name }}` + - **Actor**: @${{ github.actor }} + - **Date**: $(date +'%Y-%m-%d %H:%M:%S UTC') + + 🔄 Automated Changes + - ✅ Updated `action.yml` Docker image reference + - ✅ Updated `Makefile` fallback version + - ✅ Version auto-detected from commit messages + + 🚀 What happens when merged? + 1. 🐳 Multi-architecture Docker images built and pushed + 2. 🏷️ GitHub release created with auto-generated notes + 3. 📝 Docker Hub description updated + 4. 🧹 Release branch automatically cleaned up + + 🔍 Version Detection Logic + - `major`: Manual releases only (v0.10.2 → v1.0.0) + - `minor`: Merges from feat* branches or feat: in commits (v0.10.2 → v0.11.0) + - `patch`: All other changes (v0.10.2 → v0.10.3) + + **This PR is safe to auto-merge - it only contains version updates.** + + --- + *🤖 Fully automated release - zero manual intervention required!* diff --git a/.github/workflows/PUSH-OTHER.yml b/.github/workflows/PUSH-OTHER.yml index e92b24d..4e47b36 100644 --- a/.github/workflows/PUSH-OTHER.yml +++ b/.github/workflows/PUSH-OTHER.yml @@ -41,7 +41,7 @@ jobs: build_test: name: Build test - if: ${{ !startsWith(github.ref, 'refs/heads/dependabot') && !startsWith(github.ref, 'refs/heads/test/') }} + if: ${{ !startsWith(github.ref, 'refs/heads/dependabot') && !startsWith(github.ref, 'refs/heads/test') && !startsWith(github.ref, 'refs/heads/release') }} runs-on: ubuntu-24.04-arm steps: - name: Checkout @@ -66,7 +66,7 @@ jobs: build_and_push_test: name: Build & push test image - if: ${{ startsWith(github.ref, 'refs/heads/test/') }} + if: ${{ startsWith(github.ref, 'refs/heads/test') }} runs-on: ubuntu-24.04-arm steps: - name: Checkout @@ -93,6 +93,7 @@ jobs: pull_request: name: Create Pull Request + if: ${{ !startsWith(github.ref, 'refs/heads/release') }} runs-on: ubuntu-24.04-arm steps: - name: Checkout diff --git a/.github/workflows/RELEASE.yml b/.github/workflows/RELEASE.yml index 6f599d8..c4a8689 100644 --- a/.github/workflows/RELEASE.yml +++ b/.github/workflows/RELEASE.yml @@ -1,12 +1,87 @@ name: Release +# Trigger on pushes to release/vX.Y.Z branches to create release PRs +# Trigger on PR merges from release/vX.Y.Z branches to publish release images on: - release: - types: [published] + push: + branches: + - 'release/v*' + pull_request: + types: [closed] + branches: + - master jobs: - build_and_push: - name: Build & push release + create_release_pr: + name: Create Release PR + # Only run on push to release/vX.Y.Z branches + if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/v') + runs-on: ubuntu-24.04-arm + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract version from branch name + id: version + run: | + BRANCH_NAME=${GITHUB_REF#refs/heads/} + VERSION=${BRANCH_NAME#release/} + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "branch=${BRANCH_NAME}" >> $GITHUB_OUTPUT + echo "Version: ${VERSION}" + echo "Branch: ${BRANCH_NAME}" + + - name: Update action.yml with new version + run: | + VERSION=${{ steps.version.outputs.version }} + sed -i "s|image: docker://devopsinfra/action-commit-push:.*|image: docker://devopsinfra/action-commit-push:${VERSION}|" action.yml + echo "Updated action.yml to use version: ${VERSION}" + + - name: Update Makefile with new version + run: | + VERSION=${{ steps.version.outputs.version }} + # Update the fallback version in Makefile + sed -i "s|echo \"v[0-9]\+\.[0-9]\+\.[0-9]\+\"|echo \"${VERSION}\"|" Makefile + echo "Updated Makefile fallback version to: ${VERSION}" + + - name: Create Release Pull Request + uses: peter-evans/create-pull-request@v7.0.5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Update version to ${{ steps.version.outputs.version }} in action.yml and Makefile" + title: "🚀 Release ${{ steps.version.outputs.version }}" + body: | + ## Release ${{ steps.version.outputs.version }} + + This PR prepares a new release version ${{ steps.version.outputs.version }}. + + ### Changes in this release + - Updated `action.yml` to reference Docker image `${{ steps.version.outputs.version }}` + - Updated `Makefile` fallback version to `${{ steps.version.outputs.version }}` + + ### What happens when this PR is merged? + 1. ✅ Docker images will be built and pushed to Docker Hub and GitHub Packages + 2. ✅ A GitHub release will be created with tag `${{ steps.version.outputs.version }}` + 3. ✅ Docker Hub description will be updated + + ### Review Checklist + - [ ] Version number is correct + - [ ] CHANGELOG.md is updated (if applicable) + - [ ] Breaking changes are documented + - [ ] All tests pass + + **⚠️ Important:** Once merged, this will immediately publish Docker images to production registries. + base: master + + build_and_publish: + name: Build & Publish Release + # Only run when PR from release/vX.Y.Z branch is merged to master + if: | + github.event_name == 'pull_request' && + github.event.pull_request.merged == true && + startsWith(github.event.pull_request.head.ref, 'release/v') runs-on: ubuntu-24.04-arm steps: - name: Checkout @@ -23,10 +98,11 @@ jobs: image: tonistiigi/binfmt:latest platforms: amd64,arm64 - - name: Extract version from tag + - name: Extract version from PR branch id: version run: | - VERSION=${GITHUB_REF#refs/tags/} + BRANCH_NAME="${{ github.event.pull_request.head.ref }}" + VERSION=${BRANCH_NAME#release/} echo "version=${VERSION}" >> $GITHUB_OUTPUT echo "Version: ${VERSION}" @@ -39,6 +115,32 @@ jobs: VERSION: ${{ steps.version.outputs.version }} run: make push + - name: Create GitHub Release + uses: softprops/action-gh-release@v2.0.8 + with: + tag_name: ${{ steps.version.outputs.version }} + name: Release ${{ steps.version.outputs.version }} + body: | + ## Release ${{ steps.version.outputs.version }} + + This release was automatically created after merging the release PR. + + ### Docker Images + - **Docker Hub:** `devopsinfra/action-commit-push:${{ steps.version.outputs.version }}` + - **GitHub Packages:** `ghcr.io/devops-infra/action-commit-push:${{ steps.version.outputs.version }}` + + Both images are built for `amd64` and `arm64` architectures. + + ### Usage + ```yaml + - uses: devops-infra/action-commit-push@${{ steps.version.outputs.version }} + ``` + + For full documentation, see the [README](https://github.com/devops-infra/action-commit-push#readme). + generate_release_notes: true + draft: false + prerelease: false + - name: Docker Hub Description uses: peter-evans/dockerhub-description@v4.0.2 with: @@ -47,32 +149,12 @@ jobs: repository: ${{ vars.DOCKER_ORG_NAME }}/${{ github.event.repository.name }} short-description: ${{ github.event.repository.description }} - update_action_yml: - name: Update action.yml with new version - needs: build_and_push - runs-on: ubuntu-24.04-arm - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract version from tag - id: version - run: | - VERSION=${GITHUB_REF#refs/tags/} - echo "version=${VERSION}" >> $GITHUB_OUTPUT - echo "Version: ${VERSION}" - - - name: Update action.yml with new version + - name: Clean up release branch run: | - VERSION=${{ steps.version.outputs.version }} - sed -i "s|image: docker://devopsinfra/action-commit-push:.*|image: docker://devopsinfra/action-commit-push:${VERSION}|" action.yml - git diff action.yml - - - name: Commit updated action.yml - uses: ./ - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - commit_message: "Update action.yml to use release version ${{ steps.version.outputs.version }}" - amend: false + # Check if the release branch exists before attempting to delete it + if git ls-remote --exit-code origin "${{ github.event.pull_request.head.ref }}"; then + echo "Deleting branch \"${{ github.event.pull_request.head.ref }}\"..." + git push origin --delete "${{ github.event.pull_request.head.ref }}" + else + echo "Branch ${{ github.event.pull_request.head.ref }} does not exist. Skipping deletion." + fi diff --git a/Makefile b/Makefile index 700ea02..a3fe17c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ .PHONY: phony phony: help -# Release tag for the action -VERSION := $(or $(VERSION),v0.11.0) +# Release tag for the action - use environment variable or fall back to latest git tag +VERSION := $(or $(VERSION),$(shell git describe --tags --abbrev=0 2>/dev/null || echo "v0.11.0")) # GitHub Actions bogus variables GITHUB_REF ?= refs/heads/null diff --git a/README.md b/README.md index f880dd1..fb47fa4 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ - **Force behavior updated**: `force: true` now uses `git push --force` (breaking change) - **New parameter**: `force_with_lease` for safer force pushing with `--force-with-lease` - **Amend improvements**: Can now combine `amend: true` with `commit_message` to change commit messages +- **Release process**: Fully automated releases - zero manual work required! A powerful GitHub Action for automatically committing and pushing changes back to your repository. Perfect for automation workflows and integrates seamlessly with [devops-infra/action-pull-request](https://github.com/devops-infra/action-pull-request). @@ -201,26 +202,88 @@ When using `amend: true`, you have several options for handling the commit messa ## 🚀 Release Process -This action follows a **release-based Docker image deployment strategy**: +This action follows a **fully automated release workflow** with zero manual intervention: - **Development branches**: Only build and test Docker images (no push to Docker Hub) - **Test branches (`test/*`)**: Build and push Docker images with `test-` prefix for integration testing - **Master branch**: Only build and test Docker images (no push to Docker Hub) -- **Releases**: Docker images are built and pushed to Docker Hub only when a new GitHub release is created +- **Automatic releases**: Triggered by pushes to master - no manual steps required! - **Weekly builds**: Automated test builds run weekly and push test images -### 🏷️ Creating a New Release +### 🤖 Fully Automated Releases -1. Create a new GitHub release with a version tag (e.g., `v0.11.0`) -2. The release workflow automatically: - - Builds multi-architecture Docker images (`amd64`, `arm64`) - - Pushes images to Docker Hub with the release version tag - - Updates the `action.yml` file to reference the new Docker image version - - Updates Docker Hub description +**No manual work required!** The system automatically: + +1. **Detects when a release is needed** (new commits to master, excluding docs/dependencies) +2. **Determines version type** from merged branch names and commit messages: + - `minor`: Merges from `feat*` branches or "feat:" in commits (v0.10.2 → v0.11.0) + - `patch`: All other changes (v0.10.2 → v0.10.3) +3. **Calculates next version** using semantic versioning +4. **Creates release branch** with version updates using own action +5. **PUSH-OTHER.yml creates the PR** automatically +6. **Publishes when PR is merged** - Docker images, GitHub release, etc. + +### 🚫 **Smart Release Filtering** + +The system **skips releases** for: +- Documentation updates (`docs*` branches, `docs:` commits) +- Dependency updates (`dep*`, `dependabot/*` branches, `dep:` commits) +- README and other markdown file changes +- License updates + +### 🎯 Manual Release Trigger (Optional) + +You can also trigger releases manually via GitHub Actions UI: + +1. Go to **Actions** → **Auto-Version Release** → **Run workflow** +2. Choose release type: "minor" or "major" (or leave as "auto" for detection) +3. Click **Run workflow** +4. System handles the rest automatically! + +### 📝 Commit Message Conventions + +To help with automatic version detection, use these patterns: + +```bash +# Patch version (v0.10.2 → v0.10.3) - Most common +git commit -m "fix: resolve issue with force push" +git commit -m "docs: update README" +git commit -m "refactor: improve code structure" + +# Minor version (v0.10.2 → v0.11.0) - Feature branches or feat commits +# Create feature branch: +git checkout -b feat/new-functionality +git commit -m "add new amend functionality" +# OR use feat prefix in commits: +git commit -m "feat: add new amend functionality" +``` + +### 🌿 Branch-Based Version Detection + +The system prioritizes **branch names** for version detection: + +- **`feat/*` branches** → **Minor version bump** (v0.10.2 → v0.11.0) + ```bash + git checkout -b feat/new-feature + # When merged to master → minor version bump + ``` + +- **Other branches** → **Patch version bump** (v0.10.2 → v0.10.3) + ```bash + git checkout -b fix/bug-fix + git checkout -b docs/update-readme + git checkout -b refactor/cleanup + # When merged to master → patch version bump + ``` + +**🔢 Major Version Handling** +- **Major versions** (X in vX.Y.Z) are only incremented manually +- Use **Actions** → **Auto-Release** → **Run workflow** and select "major" +- This is reserved for breaking changes or significant API changes ### 🧪 Testing with Test Branches -For testing changes before creating a release: +For testing changes before they reach master: 1. Create a branch starting with `test/` (e.g., `test/new-feature`) 2. Push your changes to this branch @@ -228,11 +291,31 @@ For testing changes before creating a release: 4. Use the test image in other workflows: `devopsinfra/action-commit-push:test-latest` **This ensures that:** -- ✅ Master branch merges don't accidentally publish untested images -- ✅ Test branches provide safe testing environments -- ✅ Only stable, released versions are available on Docker Hub -- ✅ Users can pin to specific, tested versions -- ✅ Development and testing don't interfere with production images +- ✅ Zero manual release work - everything is automated +- ✅ Semantic versioning based on branch names and commit messages +- ✅ Test branches provide safe testing environments +- ✅ Only reviewed master commits trigger releases +- ✅ Docker images published only after PR review +- ✅ No human errors in version management + +**📌 Note**: The action references specific versions in `action.yml` for stability, and the release process keeps these up-to-date automatically. + +## 🎯 Version Usage Options + +You can use this action in different ways depending on your needs: + +### 🔄 Latest Version (Recommended) +```yaml +- uses: devops-infra/action-commit-push@master +``` +Always uses the latest release. Automatically gets new features and fixes. + +### 📌 Pinned Version (Stable) +```yaml +- uses: devops-infra/action-commit-push@v0.11.0 +``` +Uses a specific version. More predictable but requires manual updates. + ## ⚠️ Force Push Options diff --git a/action.yml b/action.yml index fc2f0d1..7e62dea 100644 --- a/action.yml +++ b/action.yml @@ -49,7 +49,7 @@ outputs: description: Name of the branch code was pushed into runs: using: docker - image: docker://devopsinfra/action-commit-push:v0.10.0 + image: docker://devopsinfra/action-commit-push:v0.11.0 env: GITHUB_TOKEN: ${{ inputs.github_token }} branding: