Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MTG-1360] release process #431

Merged
merged 5 commits into from
Feb 27, 2025
Merged

Conversation

StanChe
Copy link
Collaborator

@StanChe StanChe commented Feb 26, 2025

This PR implements a fully automated release process using GitHub Actions. The process is triggered manually and handles all steps from creating a release branch to publishing Docker images and bumping the development version.

Workflow Overview

The release process is split into two main workflows:

  1. release-prepare.yml:

    • Triggered manually via workflow_dispatch with the desired release version (e.g., 0.5.0).
    • Creates a release/vX.Y.Z branch from develop.
    • Updates version numbers in Cargo.toml and other relevant files.
    • Generates a CHANGELOG.md file using git-cliff based on Conventional Commits.
    • Creates a pull request from the release branch to main.
    • Uploads the generated changelog as an artifact.
  2. release-finalize.yml:

    • Triggered automatically when a pull request from a release/ branch is merged into main.
    • Downloads the changelog artifact.
    • Creates a Git tag (e.g., v0.5.0).
    • Pushes the tag to GitHub.
    • Creates a GitHub Release using the changelog.
    • Builds and pushes Docker images tagged with the release version.
    • Creates a pull request to merge the release branch back into develop.
    • Merges the release branch into develop.
    • Calculates the next development version (e.g., 0.5.1-dev).
    • Bumps the version on develop and pushes the changes (with automatic PR creation and merge). This includes a check to prevent race conditions if commits are made directly to develop during the release process.

Key Features

  • Fully Automated: The entire release process, from branch creation to Docker image publishing and development version bump, is automated.
  • Changelog Generation: git-cliff automatically generates a changelog based on Conventional Commits.
  • Version Number Management: cargo-edit is used to update version numbers in Cargo.toml files.
  • Docker Image Publishing: Docker images are automatically built and pushed with the release tag.
  • Development Version Bump: The development version on the develop branch is automatically bumped after the release.
  • Race Condition Prevention: A check is included to prevent merge conflicts on develop if commits are made during the release process.
  • Error Handling: Workflows use set -e to exit immediately on any command failure.
  • GitHub CLI Integration: The GitHub CLI (gh) is used for creating and merging pull requests.

How to Trigger a Release

  1. Go to the "Actions" tab in your GitHub repository.
  2. Select the "Prepare Release" workflow.
  3. Click "Run workflow".
  4. Enter the desired release version (e.g., 0.5.0) without the "v" prefix.
  5. (Optional) Specify a base commit SHA if you don't want to use the latest commit on develop.
  6. Click "Run workflow".

The rest of the process is automated. The "Prepare Release" workflow will create a pull request to main. Once that pull request is merged, the "Finalize Release" workflow will complete the release process.

- Implement release preparation/finalization

- Standardize branch naming to use release/v* format consistently

- Update documentation to reflect automated version bumping
@StanChe StanChe requested a review from obezsmertnyi February 26, 2025 16:35
@@ -142,7 +143,8 @@ jobs:
runs-on: ubuntu-latest
needs: [build-base-image, build-binary-images]
steps:
- name: Repository dispatch
- name: Repository dispatch for development
if: startsWith(github.ref, 'refs/heads/develop')
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a dispatch for prod
using the same values:
secrets.DISPATCH_TOKEN_PROD
https://api.github.com/repos/adm-metaex/aura-config-prod/dispatches

@@ -132,7 +133,7 @@ jobs:
with:
context: .
file: docker/app.Dockerfile
push: ${{ env.PUSH_CONDITION }}
push: ${{ env.PUSH_CONDITION || startsWith(github.ref, 'refs/tags/') }}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would trust only env.PUSH_CONDITION

runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
Copy link
Contributor

@obezsmertnyi obezsmertnyi Feb 26, 2025

Choose a reason for hiding this comment

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

Please use the latest v4 version

@obezsmertnyi
Copy link
Contributor

Please also update docker.yml by replacing:

- uses: actions/checkout@v4

with:

  • name: Check out repository
    uses: actions/checkout@v4
    with:
    fetch-depth: 0

tnx

@obezsmertnyi
Copy link
Contributor

We may also use concurrency:

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

This ensures that only the latest push is built.

- name: Setup GitHub CLI
run: |
set -e
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend using the GH_TOKEN environment variable
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# --- Post-Release Version Bump ---

- name: Checkout develop branch for version bump
Copy link
Contributor

@obezsmertnyi obezsmertnyi Feb 26, 2025

Choose a reason for hiding this comment

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

Please use:
uses: actions/checkout@v4
with:
ref: develop
fetch-depth: 0

- Update docker.yml to ensure proper tag pushing with PUSH_CONDITION
- Remove redundant version tag format (keeping only v-prefixed tags)
- Set GH_TOKEN at job level in both release workflows
- Remove unnecessary GitHub CLI authentication steps
Copy link
Contributor

@armyhaylenko armyhaylenko left a comment

Choose a reason for hiding this comment

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

LRFBTM

@StanChe StanChe merged commit b0cbe40 into develop Feb 27, 2025
10 checks passed
@StanChe StanChe deleted the feature/MTG-1360-release-process branch February 27, 2025 14:47
@github-actions github-actions bot mentioned this pull request Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants