> ## Documentation Index
> Fetch the complete documentation index at: https://grandcentral.backbase.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Release draft workflow

> Manual release draft creation with quality checks for AI agents

The release draft workflow allows code owners to manually create release drafts with quality validation before publishing production releases.

The release draft workflow:

* **Trigger**: Manual workflow dispatch (only by code owners)
* **Quality Checks**: Code quality validation before draft creation
* **Action Pinning**: Verifies GitHub Actions are properly pinned
* **Code Owner Verification**: Only repository code owners can trigger
* **Release Notes**: Auto-generates release notes using release-drafter

## Workflow flowchart

```mermaid theme={"system"}
%%{init: {
  'theme': 'base',
  'themeVariables': {
    'primaryColor': '#ffffff',
    'primaryBorderColor': '#295eff',
    'primaryTextColor': '#091c35',
    'lineColor': '#091c35',
    'secondaryColor': '#f3f6f9',
    'tertiaryColor': '#ebf0f5',
    'fontFamily': 'Libre Franklin, sans-serif'
  }
}}%%
flowchart TD
    Start([Manual workflow<br/>dispatch]) --> Setup[Setup project<br/>Checkout main branch]
    Setup --> CheckPin[Check action pinning]
    CheckPin --> VerifyOwner{Code owner<br/>verification}
    VerifyOwner -->|Not owner| Fail[Error:<br/>Only code owners allowed]
    VerifyOwner -->|Owner| CodeQuality[Code quality checks<br/>pylint, pytest, hadolint]
    CodeQuality --> CreateDraft[Create release draft<br/>Merge branches<br/>Update version<br/>Generate release notes]
    CreateDraft --> End([Release draft created])
    Fail --> End
```

## Workflow configuration

The release draft workflow is defined in `.github/workflows/release-draft.yaml`:

```yaml theme={"system"}
name: Create new release draft
run-name: Create new release draft

on:
  workflow_dispatch:

permissions:
  contents: read

jobs:
  create_release_draft:
    name: Create release draft
    permissions:
      contents: write
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - name: Setup project
        id: setup-project
        uses: backbase-common/gc-ai-workflows/setup-project@main
        with:
            ref: "main"
            fetchDepth: "0"
            githubPrivateKey: ${{ secrets.GIT_GITHUB_APP_PEM_FILE }}
            githubAppId: ${{ secrets.GIT_GITHUB_APP_ID }}

      - name: Check actions pinning
        id: check_pin
        uses: backbase-common/gc-ai-workflows/check-action-pinning@main

      - name: Verify release triggering actor
        shell: bash
        run: |
          is_owner=$(cat .github/CODEOWNERS | grep '@${{ github.triggering_actor }}' | wc -c)
          if [[ $is_owner -eq '0' ]]; then
            echo "::error file=.github/CODEOWNERS::Only repository code owners are allowed to trigger this action"
            exit 127
          fi
      
      - name: Run code quality checks
        id: code-quality
        uses: backbase-common/gc-ai-workflows/code-quality@main
        with:
            sourcePath: "src/"

      - name: Create release draft
        id: create-release-draft
        uses: backbase-common/gc-ai-workflows/create-release-draft@main
        with:
            githubToken: ${{ steps.setup-project.outputs.githubToken }}
```

## Release draft process

### 1. Set up project

* Authenticates using GitHub App
* Checks out code from main branch
* Sets up Python environment
* Resolves project metadata and version

### 2. Action pinning check

* Validates that external GitHub Actions are pinned to SHA versions
* Ensures security best practices
* Checks actions in `.github` directory

### 3. Code owner verification

* Verifies the triggering actor is listed in `.github/CODEOWNERS`
* Prevents unauthorized release creation
* Fails if user is not a code owner

### 4. Code quality checks

* Runs pylint for code quality
* Executes pytest for unit tests
* Runs hadolint for Dockerfile validation
* Ensures code quality before release

### 5. Create release draft

* Merges branches (develop → main by default)
* Updates version in project files
* Creates git tag with version
* Generates release notes using release-drafter
* Creates GitHub release draft

## Creating a release draft

### Steps

1. **Navigate to Actions**: Go to GitHub Actions in your repository
2. **Select Workflow**: Choose "Create new release draft"
3. **Run Workflow**: Click "Run workflow" button
4. **Wait for Completion**: Monitor workflow execution
5. **Review Draft**: Check the created release draft in Releases

### Prerequisites

* You must be listed in `.github/CODEOWNERS`
* All GitHub Actions must be pinned to SHA versions
* Code quality checks must pass
* Release-drafter configuration must exist (`.github/release-drafter.yml`)

## Configuration

> \[!TIP]
> See the [Configurations](/agentic-ai/ci-cd-workflows/configurations) page for complete setup instructions and template files.

### Release drafter

The workflow uses release-drafter to generate release notes. Create `.github/release-drafter.yml`:

```yaml theme={"system"}
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
categories:
  - title: 'Features'
    labels:
      - 'feature'
  - title: 'Bug Fixes'
    labels:
      - 'bug'
change-template: '- $TITLE (#$NUMBER) @$AUTHOR'
version-resolver:
  default: patch
```

See the [reusable components documentation](/agentic-ai/ci-cd-workflows/reusable-components#create-release-draft) for full configuration options.

## Reusable components used

This workflow uses:

* **setup-project**: Sets up Python environment and resolves metadata
* **check-action-pinning**: Validates GitHub Actions security
* **code-quality**: Runs code quality checks
* **create-release-draft**: Creates release draft with versioning

See the [Reusable Components](/agentic-ai/ci-cd-workflows/reusable-components) page for detailed documentation.

## Version management

The workflow automatically:

* Detects current version from `pyproject.toml`
* Calculates next release version
* Updates version in project files
* Creates git tag with version
* Generates release notes

## Best practices

* **Code Owner Verification**: Ensure CODEOWNERS file is up to date
* **Action Pinning**: Keep all GitHub Actions pinned to SHA versions
* **Quality Checks**: Address any code quality issues before creating release
* **Release Notes**: Review auto-generated release notes before publishing
* **Version Verification**: Verify version numbers are correct

## Troubleshooting

### Common issues

1. **Code Owner Check Failure**
   * Ensure you're listed in `.github/CODEOWNERS`
   * Format: `* @username` or `path/ @username`

2. **Action Pinning Failures**
   * Pin all external GitHub Actions to SHA versions
   * Use `actions/checkout@v4` format, not `@main` or `@v4`

3. **Quality Gate Failures**
   * Fix pylint errors
   * Address failing tests
   * Fix Dockerfile linting issues

4. **Release Draft Creation Failures**
   * Verify release-drafter configuration exists
   * Check GitHub App credentials
   * Ensure proper repository permissions

### Verification

* Check workflow logs for detailed error messages
* Verify CODEOWNERS file format
* Review code quality check results
* Confirm release-drafter configuration

## Next steps

* [Publish the release](/agentic-ai/ci-cd-workflows/release-workflow)
* [Learn about hotfix releases](/agentic-ai/ci-cd-workflows/hotfix-release-workflow)
* [Review CI/CD overview](/agentic-ai/ci-cd-workflows/overview)
