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
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
35 changes: 31 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@ on:
branches: [develop]
tags: ["v*"]

# Add concurrency to cancel in-progress runs on the same ref
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Add permissions block for GitHub Container Registry access
permissions:
contents: read
packages: write

env:
PUSH_CONDITION: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && contains(fromJSON('["refs/head/main", "refs/head/develop"]'), github.event.workflow_dispatch.ref)) }}
PUSH_CONDITION: ${{ github.event_name == 'push' && (contains(fromJSON('["refs/heads/develop"]'), github.ref) || startsWith(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch' && contains(fromJSON('["refs/heads/develop"]'), github.ref) }}

jobs:
build-base-image:
Expand All @@ -23,7 +28,10 @@ jobs:
version: ${{ steps.version.outputs.version }}

steps:
- uses: actions/checkout@v4
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -82,7 +90,10 @@ jobs:
rocksdb_backup,
]
steps:
- uses: actions/checkout@v4 # Need to checkout code for Dockerfile
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -142,7 +153,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

run: |
curl -X POST \
-H "Authorization: token ${{ secrets.DISPATCH_TOKEN_DEV }}" \
Expand All @@ -155,3 +167,18 @@ jobs:
"version": "${{ needs.build-base-image.outputs.version }}"
}
}'
- name: Repository dispatch for production
if: startsWith(github.ref, 'refs/tags/')
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.DISPATCH_TOKEN_PROD }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/adm-metaex/aura-config-prod/dispatches \
-d '{
"event_type": "deploy",
"client_payload": {
"services": "${{ env.PUSH_CONDITION && 'ingester,slot_persister,backfill,api,synchronizer,rocksdb_backup' || '' }}",
"version": "${{ needs.build-base-image.outputs.version }}"
}
}'
124 changes: 124 additions & 0 deletions .github/workflows/release-finalize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Finalize Release

on:
pull_request:
types: [closed]
branches:
- main

# Add permissions for GitHub operations
permissions:
contents: write
pull-requests: write

jobs:
finalize-release:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper tagging

- name: Setup Git Identity
run: |
set -e
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Download changelog artifact
uses: actions/download-artifact@v4
with:
name: changelog
path: .

- name: Get release version
id: get_version
run: |
set -e
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
# We only support release/v* format now
VERSION=${BRANCH_NAME#release/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag_name=$VERSION" >> $GITHUB_OUTPUT
- name: Create and push tag
run: |
set -e
git tag -a ${{ steps.get_version.outputs.tag_name }} -m "Release ${{ steps.get_version.outputs.tag_name }}"
git push origin ${{ steps.get_version.outputs.tag_name }}
# This tag push will automatically trigger the docker.yml workflow for building images
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.tag_name }}
name: Release ${{ steps.get_version.outputs.tag_name }}
body_path: CHANGELOG.md # Use the downloaded changelog
generate_release_notes: false # We're using our own changelog
draft: false
prerelease: false

- name: Create PR to develop
run: |
set -e
gh pr create --base develop --head ${{ github.event.pull_request.head.ref }} \
--title "Merge ${{ github.event.pull_request.head.ref }} into develop" \
--body "Merge release branch into develop."
- name: Merge into develop
run: |
set -e
PR_NUMBER=$(gh pr list --head ${{ github.event.pull_request.head.ref }} --base develop --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
gh pr merge --repo ${{ github.repository }} --merge --auto $PR_NUMBER
else
echo "No PR found to merge into develop"
exit 1
fi
# --- 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

uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper tagging
ref: develop

- name: Install dependencies for version bump
run: |
set -e
sudo apt-get update && sudo apt-get install -y protobuf-compiler
cargo install cargo-edit
- name: Calculate and apply next development version
id: calculate_next_version
run: |
set -e
# Extract version without 'v' prefix
RAW_VERSION=${{ steps.get_version.outputs.version }}
VERSION_WITHOUT_V="${RAW_VERSION#v}"
IFS='.' read -ra VERSION_PARTS <<< "$VERSION_WITHOUT_V"
MAJOR="${VERSION_PARTS[0]}"
MINOR="${VERSION_PARTS[1]}"
PATCH=$((VERSION_PARTS[2] + 1)) # Increment the patch version
NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}-dev"
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "Setting develop version to $NEXT_VERSION"
# Update Cargo.toml versions
find . -name "Cargo.toml" -type f -exec cargo set-version $NEXT_VERSION --manifest-path {} \;
# Update any other version references
if [ -f "VERSION" ]; then
echo "$NEXT_VERSION" > VERSION
fi
# Commit and push the version bump directly to develop
git add -A
git commit -m "chore: bump version to $NEXT_VERSION [skip ci]"
git push origin develop
147 changes: 147 additions & 0 deletions .github/workflows/release-prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Prepare Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version number (without v prefix, e.g. 0.5.0)'
required: true
type: string
base_commit:
description: 'Base commit SHA (leave empty to use latest develop)'
required: false
type: string
default: ''

# Add permissions for GitHub operations
permissions:
contents: write
pull-requests: write

jobs:
prepare-release:
runs-on: ubuntu-latest
outputs:
version: ${{ inputs.version }} # Output the version for use in other jobs
tag_name: v${{ inputs.version }}
release_branch: release/v${{ inputs.version }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.base_commit || 'develop' }}
fetch-depth: 0 # Fetch all history for changelog generation

- name: Validate input version
run: |
set -e
# Make sure the version follows semantic versioning format
if ! echo "${{ inputs.version }}" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Error: Version must follow semantic versioning format (e.g., 0.5.0)"
exit 1
fi
- name: Setup Git Identity
run: |
set -e
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Install dependencies
run: |
set -e
sudo apt-get update && sudo apt-get install -y protobuf-compiler
cargo install cargo-edit
cargo install git-cliff
- name: Create release branch
run: |
set -e
# Using standardized format: release/v{version}
RELEASE_BRANCH="release/v${{ inputs.version }}"
echo "Creating branch $RELEASE_BRANCH"
git checkout -b $RELEASE_BRANCH
echo "RELEASE_BRANCH=$RELEASE_BRANCH" >> $GITHUB_ENV
- name: Update version numbers
run: |
set -e
# Update Cargo.toml versions
find . -name "Cargo.toml" -type f -exec cargo set-version ${{ inputs.version }} --manifest-path {} \;
# Update any other version references (add any other files that contain version numbers)
if [ -f "VERSION" ]; then
echo "${{ inputs.version }}" > VERSION
fi
git add -A
git commit -m "chore: bump version to ${{ inputs.version }}"
- name: Generate changelog
id: changelog
run: |
set -e
# Generate changelog using git-cliff
git-cliff --config cliff.toml --tag "v${{ inputs.version }}" --output CHANGELOG.md
# Generate a shorter version for PR description
git-cliff --config cliff.toml --tag "v${{ inputs.version }}" --strip header,footer > .changelog_content
git add CHANGELOG.md
git commit -m "docs: add changelog for v${{ inputs.version }}"
- name: Verify changelog
run: |
set -e
# Check that the changelog file exists and has content
if [ ! -s CHANGELOG.md ]; then
echo "Error: CHANGELOG.md is empty or does not exist"
exit 1
fi
# Check that the changelog contains the version we're releasing
if ! grep -q "v${{ inputs.version }}" CHANGELOG.md; then
echo "Error: CHANGELOG.md does not contain version v${{ inputs.version }}"
echo "Contents of CHANGELOG.md:"
cat CHANGELOG.md
exit 1
fi
# Check that the changelog has sections
if ! grep -q "###" CHANGELOG.md; then
echo "Warning: CHANGELOG.md does not contain any sections (###)"
echo "This might be ok if there are no conventional commits, but please verify"
fi
echo "Changelog verification passed!"
- name: Push release branch
run: |
set -e
git push -u origin $RELEASE_BRANCH
- name: Create Pull Request
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: main
head: ${{ env.RELEASE_BRANCH }}
title: "Release v${{ inputs.version }}"
body-path: .changelog_content
draft: false

- name: PR info
run: |
set -e
echo "Pull Request created: ${{ steps.create-pr.outputs.pull-request-url }}"
echo "Please review the PR, make any necessary adjustments, and merge when ready."
- name: Upload changelog artifact
uses: actions/upload-artifact@v4
with:
name: changelog
path: CHANGELOG.md
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@ clippy:
test:
@cargo clean -p postgre-client -p rocks-db -p interface
@cargo test --features integration_tests

# Ensure git-cliff is installed
ensure-git-cliff:
@which git-cliff > /dev/null || cargo install git-cliff

# Generate a changelog using git-cliff
changelog:
@git-cliff --output CHANGELOG.md
Loading
Loading