Skip to content

Commit b0cbe40

Browse files
authored
chore: [MTG-1360] release process (#431)
* chore: set an appropriate 0.1 version * chore(ci): standardize release workflows and branch naming - Implement release preparation/finalization - Standardize branch naming to use release/v* format consistently - Update documentation to reflect automated version bumping * chore: cliff.toml nit and makefile cleanup * chore(ci): improve GitHub workflows for release process - 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 * chore(ci): use proper checkout action
1 parent 946d4e4 commit b0cbe40

File tree

8 files changed

+466
-6
lines changed

8 files changed

+466
-6
lines changed

.github/workflows/docker.yml

+31-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ on:
88
branches: [develop]
99
tags: ["v*"]
1010

11+
# Add concurrency to cancel in-progress runs on the same ref
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
1116
# Add permissions block for GitHub Container Registry access
1217
permissions:
1318
contents: read
1419
packages: write
1520

1621
env:
17-
PUSH_CONDITION: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && contains(fromJSON('["refs/head/main", "refs/head/develop"]'), github.event.workflow_dispatch.ref)) }}
22+
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) }}
1823

1924
jobs:
2025
build-base-image:
@@ -23,7 +28,10 @@ jobs:
2328
version: ${{ steps.version.outputs.version }}
2429

2530
steps:
26-
- uses: actions/checkout@v4
31+
- name: Check out repository
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
2735
- name: Login to GitHub Container Registry
2836
uses: docker/login-action@v3
2937
with:
@@ -82,7 +90,10 @@ jobs:
8290
rocksdb_backup,
8391
]
8492
steps:
85-
- uses: actions/checkout@v4 # Need to checkout code for Dockerfile
93+
- name: Check out repository
94+
uses: actions/checkout@v4
95+
with:
96+
fetch-depth: 0
8697
- name: Login to GitHub Container Registry
8798
uses: docker/login-action@v3
8899
with:
@@ -142,7 +153,8 @@ jobs:
142153
runs-on: ubuntu-latest
143154
needs: [build-base-image, build-binary-images]
144155
steps:
145-
- name: Repository dispatch
156+
- name: Repository dispatch for development
157+
if: startsWith(github.ref, 'refs/heads/develop')
146158
run: |
147159
curl -X POST \
148160
-H "Authorization: token ${{ secrets.DISPATCH_TOKEN_DEV }}" \
@@ -155,3 +167,18 @@ jobs:
155167
"version": "${{ needs.build-base-image.outputs.version }}"
156168
}
157169
}'
170+
171+
- name: Repository dispatch for production
172+
if: startsWith(github.ref, 'refs/tags/')
173+
run: |
174+
curl -X POST \
175+
-H "Authorization: token ${{ secrets.DISPATCH_TOKEN_PROD }}" \
176+
-H "Accept: application/vnd.github+json" \
177+
https://api.github.com/repos/adm-metaex/aura-config-prod/dispatches \
178+
-d '{
179+
"event_type": "deploy",
180+
"client_payload": {
181+
"services": "${{ env.PUSH_CONDITION && 'ingester,slot_persister,backfill,api,synchronizer,rocksdb_backup' || '' }}",
182+
"version": "${{ needs.build-base-image.outputs.version }}"
183+
}
184+
}'
+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Finalize Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
# Add permissions for GitHub operations
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
14+
jobs:
15+
finalize-release:
16+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')
17+
runs-on: ubuntu-latest
18+
env:
19+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
steps:
21+
- name: Check out repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0 # Fetch all history for proper tagging
25+
26+
- name: Setup Git Identity
27+
run: |
28+
set -e
29+
git config --global user.name "GitHub Actions"
30+
git config --global user.email "[email protected]"
31+
32+
- name: Download changelog artifact
33+
uses: actions/download-artifact@v4
34+
with:
35+
name: changelog
36+
path: .
37+
38+
- name: Get release version
39+
id: get_version
40+
run: |
41+
set -e
42+
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
43+
# We only support release/v* format now
44+
VERSION=${BRANCH_NAME#release/}
45+
echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
echo "tag_name=$VERSION" >> $GITHUB_OUTPUT
47+
48+
- name: Create and push tag
49+
run: |
50+
set -e
51+
git tag -a ${{ steps.get_version.outputs.tag_name }} -m "Release ${{ steps.get_version.outputs.tag_name }}"
52+
git push origin ${{ steps.get_version.outputs.tag_name }}
53+
# This tag push will automatically trigger the docker.yml workflow for building images
54+
55+
- name: Create GitHub Release
56+
uses: softprops/action-gh-release@v2
57+
with:
58+
tag_name: ${{ steps.get_version.outputs.tag_name }}
59+
name: Release ${{ steps.get_version.outputs.tag_name }}
60+
body_path: CHANGELOG.md # Use the downloaded changelog
61+
generate_release_notes: false # We're using our own changelog
62+
draft: false
63+
prerelease: false
64+
65+
- name: Create PR to develop
66+
run: |
67+
set -e
68+
gh pr create --base develop --head ${{ github.event.pull_request.head.ref }} \
69+
--title "Merge ${{ github.event.pull_request.head.ref }} into develop" \
70+
--body "Merge release branch into develop."
71+
72+
- name: Merge into develop
73+
run: |
74+
set -e
75+
PR_NUMBER=$(gh pr list --head ${{ github.event.pull_request.head.ref }} --base develop --json number --jq '.[0].number')
76+
if [ -n "$PR_NUMBER" ]; then
77+
gh pr merge --repo ${{ github.repository }} --merge --auto $PR_NUMBER
78+
else
79+
echo "No PR found to merge into develop"
80+
exit 1
81+
fi
82+
83+
# --- Post-Release Version Bump ---
84+
85+
- name: Checkout develop branch for version bump
86+
uses: actions/checkout@v4
87+
with:
88+
fetch-depth: 0 # Fetch all history for proper tagging
89+
ref: develop
90+
91+
- name: Install dependencies for version bump
92+
run: |
93+
set -e
94+
sudo apt-get update && sudo apt-get install -y protobuf-compiler
95+
cargo install cargo-edit
96+
97+
- name: Calculate and apply next development version
98+
id: calculate_next_version
99+
run: |
100+
set -e
101+
# Extract version without 'v' prefix
102+
RAW_VERSION=${{ steps.get_version.outputs.version }}
103+
VERSION_WITHOUT_V="${RAW_VERSION#v}"
104+
105+
IFS='.' read -ra VERSION_PARTS <<< "$VERSION_WITHOUT_V"
106+
MAJOR="${VERSION_PARTS[0]}"
107+
MINOR="${VERSION_PARTS[1]}"
108+
PATCH=$((VERSION_PARTS[2] + 1)) # Increment the patch version
109+
NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}-dev"
110+
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
111+
echo "Setting develop version to $NEXT_VERSION"
112+
113+
# Update Cargo.toml versions
114+
find . -name "Cargo.toml" -type f -exec cargo set-version $NEXT_VERSION --manifest-path {} \;
115+
116+
# Update any other version references
117+
if [ -f "VERSION" ]; then
118+
echo "$NEXT_VERSION" > VERSION
119+
fi
120+
121+
# Commit and push the version bump directly to develop
122+
git add -A
123+
git commit -m "chore: bump version to $NEXT_VERSION [skip ci]"
124+
git push origin develop

.github/workflows/release-prepare.yml

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version number (without v prefix, e.g. 0.5.0)'
8+
required: true
9+
type: string
10+
base_commit:
11+
description: 'Base commit SHA (leave empty to use latest develop)'
12+
required: false
13+
type: string
14+
default: ''
15+
16+
# Add permissions for GitHub operations
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
21+
jobs:
22+
prepare-release:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
version: ${{ inputs.version }} # Output the version for use in other jobs
26+
tag_name: v${{ inputs.version }}
27+
release_branch: release/v${{ inputs.version }}
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
steps:
32+
- name: Check out repository
33+
uses: actions/checkout@v4
34+
with:
35+
ref: ${{ inputs.base_commit || 'develop' }}
36+
fetch-depth: 0 # Fetch all history for changelog generation
37+
38+
- name: Validate input version
39+
run: |
40+
set -e
41+
# Make sure the version follows semantic versioning format
42+
if ! echo "${{ inputs.version }}" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'; then
43+
echo "Error: Version must follow semantic versioning format (e.g., 0.5.0)"
44+
exit 1
45+
fi
46+
47+
- name: Setup Git Identity
48+
run: |
49+
set -e
50+
git config --global user.name "GitHub Actions"
51+
git config --global user.email "[email protected]"
52+
53+
- name: Install dependencies
54+
run: |
55+
set -e
56+
sudo apt-get update && sudo apt-get install -y protobuf-compiler
57+
cargo install cargo-edit
58+
cargo install git-cliff
59+
60+
- name: Create release branch
61+
run: |
62+
set -e
63+
# Using standardized format: release/v{version}
64+
RELEASE_BRANCH="release/v${{ inputs.version }}"
65+
echo "Creating branch $RELEASE_BRANCH"
66+
git checkout -b $RELEASE_BRANCH
67+
echo "RELEASE_BRANCH=$RELEASE_BRANCH" >> $GITHUB_ENV
68+
69+
- name: Update version numbers
70+
run: |
71+
set -e
72+
# Update Cargo.toml versions
73+
find . -name "Cargo.toml" -type f -exec cargo set-version ${{ inputs.version }} --manifest-path {} \;
74+
75+
# Update any other version references (add any other files that contain version numbers)
76+
if [ -f "VERSION" ]; then
77+
echo "${{ inputs.version }}" > VERSION
78+
fi
79+
80+
git add -A
81+
git commit -m "chore: bump version to ${{ inputs.version }}"
82+
83+
- name: Generate changelog
84+
id: changelog
85+
run: |
86+
set -e
87+
# Generate changelog using git-cliff
88+
git-cliff --config cliff.toml --tag "v${{ inputs.version }}" --output CHANGELOG.md
89+
90+
# Generate a shorter version for PR description
91+
git-cliff --config cliff.toml --tag "v${{ inputs.version }}" --strip header,footer > .changelog_content
92+
93+
git add CHANGELOG.md
94+
git commit -m "docs: add changelog for v${{ inputs.version }}"
95+
96+
- name: Verify changelog
97+
run: |
98+
set -e
99+
# Check that the changelog file exists and has content
100+
if [ ! -s CHANGELOG.md ]; then
101+
echo "Error: CHANGELOG.md is empty or does not exist"
102+
exit 1
103+
fi
104+
105+
# Check that the changelog contains the version we're releasing
106+
if ! grep -q "v${{ inputs.version }}" CHANGELOG.md; then
107+
echo "Error: CHANGELOG.md does not contain version v${{ inputs.version }}"
108+
echo "Contents of CHANGELOG.md:"
109+
cat CHANGELOG.md
110+
exit 1
111+
fi
112+
113+
# Check that the changelog has sections
114+
if ! grep -q "###" CHANGELOG.md; then
115+
echo "Warning: CHANGELOG.md does not contain any sections (###)"
116+
echo "This might be ok if there are no conventional commits, but please verify"
117+
fi
118+
119+
echo "Changelog verification passed!"
120+
121+
- name: Push release branch
122+
run: |
123+
set -e
124+
git push -u origin $RELEASE_BRANCH
125+
126+
- name: Create Pull Request
127+
id: create-pr
128+
uses: peter-evans/create-pull-request@v5
129+
with:
130+
token: ${{ secrets.GITHUB_TOKEN }}
131+
base: main
132+
head: ${{ env.RELEASE_BRANCH }}
133+
title: "Release v${{ inputs.version }}"
134+
body-path: .changelog_content
135+
draft: false
136+
137+
- name: PR info
138+
run: |
139+
set -e
140+
echo "Pull Request created: ${{ steps.create-pr.outputs.pull-request-url }}"
141+
echo "Please review the PR, make any necessary adjustments, and merge when ready."
142+
143+
- name: Upload changelog artifact
144+
uses: actions/upload-artifact@v4
145+
with:
146+
name: changelog
147+
path: CHANGELOG.md

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,11 @@ clippy:
4747
test:
4848
@cargo clean -p postgre-client -p rocks-db -p interface
4949
@cargo test --features integration_tests
50+
51+
# Ensure git-cliff is installed
52+
ensure-git-cliff:
53+
@which git-cliff > /dev/null || cargo install git-cliff
54+
55+
# Generate a changelog using git-cliff
56+
changelog:
57+
@git-cliff --output CHANGELOG.md

0 commit comments

Comments
 (0)