Skip to content

Commit 8d7fcfe

Browse files
authored
ci: allow for autorelease script (only patch versions for now) (#104)
1 parent d05c0ae commit 8d7fcfe

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

.github/workflows/autorelease.yml

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

0 commit comments

Comments
 (0)