Skip to content

Commit 01d6e33

Browse files
authored
Automate release process (#188)
## Problem Automate release process ## Solution Add release as a github workflow. I'll be adding more functionality iteratively i.e. in next PRs. This PR is for testing basic gradle publish flow. ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan NA
1 parent ffcee4b commit 01d6e33

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: 'Git ref to build (branch name or SHA)'
8+
required: true
9+
type: string
10+
default: 'main'
11+
releaseLevel:
12+
description: 'Release level'
13+
required: true
14+
type: choice
15+
default: 'patch'
16+
options:
17+
- 'patch' # bug fixes
18+
- 'minor' # new features, backwards compatible
19+
- 'major' # breaking changes
20+
21+
jobs:
22+
release:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v3
27+
with:
28+
ref: ${{ github.event.inputs.ref }}
29+
30+
- name: Set up JDK 8
31+
uses: actions/setup-java@v3
32+
with:
33+
java-version: '8'
34+
distribution: 'temurin'
35+
36+
- name: Bump version
37+
run: |
38+
# Read current version
39+
CURRENT_VERSION=$(grep "pineconeClientVersion" gradle.properties | cut -d'=' -f2 | tr -d ' ')
40+
41+
# Split version into components
42+
IFS='.' read -r major minor patch <<< "$CURRENT_VERSION"
43+
44+
# Bump version based on release level
45+
case "${{ github.event.inputs.releaseLevel }}" in
46+
"major")
47+
NEW_VERSION="$((major + 1)).0.0"
48+
;;
49+
"minor")
50+
NEW_VERSION="$major.$((minor + 1)).0"
51+
;;
52+
"patch")
53+
NEW_VERSION="$major.$minor.$((patch + 1))"
54+
;;
55+
esac
56+
57+
# Update gradle.properties
58+
sed -i "s/pineconeClientVersion = .*/pineconeClientVersion = $NEW_VERSION/" gradle.properties
59+
60+
# Set output for later steps
61+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
62+
63+
- name: Build with Gradle
64+
run: ./gradlew clean build
65+
66+
- name: Publish to Maven Central
67+
env:
68+
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }}
69+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
70+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
71+
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
72+
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
73+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
74+
75+
- name: Create GitHub Release
76+
uses: softprops/action-gh-release@v1
77+
with:
78+
name: Release v${{ env.NEW_VERSION }}
79+
tag_name: v${{ env.NEW_VERSION }}
80+
body: |
81+
Release v${{ env.NEW_VERSION }}
82+
83+
This release was created automatically by the release workflow.
84+
draft: false
85+
prerelease: false
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)