Skip to content

Commit d4106c0

Browse files
committed
release workflow
1 parent 5cbb878 commit d4106c0

File tree

4 files changed

+145
-3
lines changed

4 files changed

+145
-3
lines changed

.github/workflows/build-docs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ on:
2323
description: "Branch to build from"
2424
required: false
2525
type: string
26+
2627
jobs:
2728
build-docs:
2829
runs-on: ["ubuntu-latest"]
@@ -49,4 +50,4 @@ jobs:
4950
- name: Publish docs
5051
if: ${{ inputs.publish }}
5152
run: |
52-
mkdocs gh-deploy
53+
mkdocs gh-deploy

.github/workflows/build-packages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Build Packages
22

33
on:
4-
push:
54
workflow_dispatch:
65
inputs:
76
version:
@@ -12,6 +11,7 @@ on:
1211
description: "Branch to build"
1312
required: false
1413
type: string
14+
workflow_call:
1515

1616
jobs:
1717
build-packages:
@@ -134,4 +134,4 @@ jobs:
134134
with:
135135
name: memgraph-logs-wheel-${{ matrix.python-version }}
136136
path: /var/log/memgraph
137-
overwrite: true
137+
overwrite: true

.github/workflows/create-github-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ jobs:
5151
body: ${{ steps.changelog.outputs.CHANGELOG }}
5252
draft: true
5353
prerelease: false
54+
5455

.github/workflows/release.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Release GQLAlchemy
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Version to release"
8+
required: false
9+
type: string
10+
build_docs:
11+
description: "Build docs"
12+
required: false
13+
type: boolean
14+
default: false
15+
publish_packages:
16+
description: "Publish packages"
17+
required: false
18+
type: boolean
19+
default: false
20+
test:
21+
description: "Test"
22+
required: false
23+
type: boolean
24+
default: true
25+
26+
jobs:
27+
create-release-branch:
28+
name: Create Release Branch
29+
runs-on: ["ubuntu-latest"]
30+
outputs:
31+
release_branch: ${{ steps.create_release_branch.outputs.RELEASE_BRANCH }}
32+
steps:
33+
- name: Checkout Code
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0 # Fetch all history for changelog generation
37+
38+
- name: Configure Git
39+
run: |
40+
git config user.name "github-actions"
41+
git config user.email "[email protected]"
42+
43+
- name: Create Release Branch
44+
id: create_release_branch
45+
run: |
46+
# Parse version and create branch name
47+
if [[ "${{ inputs.version }}" =~ ^([0-9]+\.[0-9]+)\.0$ ]]; then
48+
# If version ends in .0, use shortened form (e.g., 1.2.0 -> release/1.2)
49+
BRANCH_NAME="release/${BASH_REMATCH[1]}"
50+
else
51+
# Otherwise use full version (e.g., 1.2.1 -> release/1.2.1)
52+
BRANCH_NAME="release/${{ inputs.version }}"
53+
fi
54+
55+
# Check if branch exists
56+
if git show-ref --verify --quiet "refs/heads/$BRANCH_NAME" || git show-ref --verify --quiet "refs/remotes/origin/$BRANCH_NAME"; then
57+
echo "::error::Branch $BRANCH_NAME already exists!"
58+
exit 1
59+
fi
60+
git checkout -b "$BRANCH_NAME"
61+
62+
# Export branch name for later steps
63+
echo "RELEASE_BRANCH=$BRANCH_NAME" >> $GITHUB_ENV
64+
echo "RELEASE_BRANCH=$BRANCH_NAME" >> $GITHUB_OUTPUT
65+
66+
- name: Set version
67+
run: |
68+
sed -i "s/^version = .*/version = \"${{ inputs.version }}\"/" pyproject.toml
69+
70+
- name: Commit version
71+
run: |
72+
git add pyproject.toml
73+
git commit -m "Release v${{ inputs.version }}"
74+
git push origin "$RELEASE_BRANCH"
75+
76+
- name: Create Release Tag
77+
run: |
78+
git tag -a v${{ inputs.version }} -m "Release v${{ inputs.version }}"
79+
git push origin v${{ inputs.version }}
80+
81+
- name: Create Release Pull Request
82+
run: |
83+
gh pr create --base main --head "$RELEASE_BRANCH" --title "Release v${{ inputs.version }}" --body "Release v${{ inputs.version }}"
84+
85+
build-packages:
86+
needs: create-release-branch
87+
name: Build Packages
88+
uses: ./.github/workflows/build-packages.yml
89+
with:
90+
version: ${{ inputs.version }}
91+
branch: ${{ needs.create-release-branch.outputs.RELEASE_BRANCH }}
92+
secrets: inherit
93+
94+
publish-packages:
95+
needs: [create-release-branch, build-packages]
96+
name: Publish Packages
97+
if: ${{ inputs.publish_packages == true }}
98+
runs-on: ["ubuntu-latest"]
99+
steps:
100+
- name: Checkout Code
101+
uses: actions/checkout@v4
102+
with:
103+
ref: ${{ needs.create-release-branch.outputs.RELEASE_BRANCH }}
104+
fetch-depth: 0 # Fetch all history for changelog generation
105+
106+
- name: Download packages
107+
uses: actions/download-artifact@v4
108+
with:
109+
name: packages
110+
path: dist
111+
112+
- name: Publish packages
113+
if: ${{ inputs.test == false }}
114+
run: |
115+
poetry publish --username ${{ secrets.PYPI_USERNAME }} --password ${{ secrets.PYPI_PASSWORD }}
116+
117+
- name: Publish Packages (Test PyPI)
118+
if: ${{ inputs.test == true }}
119+
run: |
120+
poetry config repositories.testpypi https://test.pypi.org/legacy/
121+
poetry publish --username ${{ secrets.TESTPYPI_USERNAME }} --password ${{ secrets.TESTPYPI_PASSWORD }} --repository testpypi
122+
123+
build-docs:
124+
needs: [create-release-branch, build-packages, publish-packages]
125+
name: Build Docs
126+
uses: ./.github/workflows/build-docs.yml
127+
if: ${{ inputs.build_docs == true }}
128+
with:
129+
publish: ${{ inputs.test == false }}
130+
branch: ${{ needs.create-release-branch.outputs.RELEASE_BRANCH }}
131+
secrets: inherit
132+
133+
create-github-release:
134+
needs: [create-release-branch, build-packages, publish-packages, build-docs]
135+
name: Create GitHub Release
136+
uses: ./.github/workflows/create-github-release.yml
137+
with:
138+
version: ${{ inputs.version }}
139+
branch: ${{ needs.create-release-branch.outputs.RELEASE_BRANCH }}
140+
secrets: inherit

0 commit comments

Comments
 (0)