Skip to content

Commit d171707

Browse files
Merge branch 'main' into release/0.4
2 parents a522ead + d639e95 commit d171707

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

.github/workflows/autorelease.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Auto Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_type:
7+
description: "Select the type of release"
8+
type: choice
9+
options:
10+
- patch
11+
- minor
12+
- major
13+
14+
jobs:
15+
release:
16+
name: Auto Release
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
# Checkout the repository
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
fetch-tags: true
26+
show-progress: true
27+
token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
28+
29+
# Configure Git
30+
- name: Configure Git
31+
run: |
32+
git config --global user.name ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
33+
git config --global user.email ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
34+
35+
# Retrieve the latest release tag from GitHub
36+
- name: Get Latest Release Branch
37+
id: get-release
38+
run: |
39+
# Fetch all tags
40+
git fetch --tags
41+
42+
# Get the latest release tag
43+
LATEST_RELEASE=$(git tag --list "v*" --sort=-version:refname | head -n 1)
44+
45+
# Parse major and minor version numbers
46+
if [[ "$LATEST_RELEASE" =~ ^v([0-9]+)\.([0-9]+)\.[0-9]+$ ]]; then
47+
MAJOR="${BASH_REMATCH[1]}"
48+
MINOR="${BASH_REMATCH[2]}"
49+
RELEASE_BRANCH="release/${MAJOR}.${MINOR}"
50+
echo "Latest release tag: $LATEST_RELEASE"
51+
echo "Associated release branch: $RELEASE_BRANCH"
52+
else
53+
echo "Error: Unable to parse the latest release tag."
54+
exit 1
55+
fi
56+
57+
# Export the release branch name
58+
echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_ENV
59+
60+
# Run the patch release script
61+
- name: Run Patch Release Script
62+
if: ${{ github.event.inputs.release_type == 'patch' }}
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
65+
RELEASE_BRANCH: ${{ env.RELEASE_BRANCH }}
66+
run: |
67+
./scripts/patch_release.sh ${{ env.RELEASE_BRANCH }}
68+
69+
# Run the minor release script
70+
- name: Run Minor Release Script
71+
if: ${{ github.event.inputs.release_type == 'minor' }}
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
74+
run: |
75+
# TODO: Implement the minor release script
76+
echo "Minor release script not implemented."
77+
exit 1
78+
79+
# Run the major release script
80+
- name: Run Major Release Script
81+
if: ${{ github.event.inputs.release_type == 'major' }}
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
84+
run: |
85+
# TODO: Implement the major release script
86+
echo "Major release script not implemented."
87+
exit 1

scripts/patch_release.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
# Ensure the script exits if any command fails
4+
set -e
5+
6+
# Check if two arguments are passed
7+
if [ "$#" -ne 1 ]; then
8+
echo "Usage: $0 <release-branch-name>"
9+
exit 1
10+
fi
11+
12+
# Assign arguments to variables
13+
RELEASE_BRANCH=$1
14+
15+
# Checkout main branch
16+
git checkout main
17+
18+
# Pull the latest changes
19+
git pull
20+
21+
# Checkout release branch
22+
git checkout $RELEASE_BRANCH
23+
24+
# Merge the main branch
25+
git merge main --commit --no-edit
26+
27+
# Automatically bump the patch version (Y)
28+
VERSION_FILE="ansys/api/geometry/VERSION"
29+
if [ ! -f "$VERSION_FILE" ]; then
30+
echo "Error: VERSION file not found at $VERSION_FILE"
31+
exit 1
32+
fi
33+
34+
# Extract current version and bump Y
35+
CURRENT_VERSION=$(cat "$VERSION_FILE")
36+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
37+
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
38+
39+
# Update the VERSION file
40+
echo "$NEW_VERSION" > "$VERSION_FILE"
41+
42+
# Commit the release bump
43+
git add "$VERSION_FILE"
44+
git commit -m "release: v$NEW_VERSION"
45+
46+
# Push to origin
47+
git push origin $RELEASE_BRANCH
48+
49+
# Tag the release
50+
git tag "v$NEW_VERSION"
51+
git push origin "v$NEW_VERSION"
52+
53+
# Checkout main again
54+
git checkout main

0 commit comments

Comments
 (0)