Skip to content

Commit

Permalink
chore: add deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mlz11 committed Mar 12, 2024
1 parent 3cfa7da commit 62477f3
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/spring-search-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: SpringSearch Deploy

on:
pull_request:
types:
- closed
branches:
- master

env:
TAG_NAME: ${{ github.event.pull_request.title }}

jobs:
release-maven-central:
if: contains(github.head_ref, 'bump/v') && github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
fetch-depth: '0'

- name: Import GPG signing key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.MAVEN_SIGNING_KEY }}
passphrase: ${{ secrets.MAVEN_SIGNING_KEY_PASSPHRASE }}

- name: Install JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
server-id: maven-central-release
server-username: MVN_CENTRAL_USERNAME
server-password: MVN_CENTRAL_PASSWORD

- name: Release to Maven repo
run: |
mvn -Dgpg.keyname=${{ secrets.GPG_KEY_NAME }} -Dgpg.passphrase=${{ secrets.MAVEN_SIGNING_KEY_PASSPHRASE }} \
-Drevision=${{ env.TAG_NAME }} deploy
env:
MVN_CENTRAL_USERNAME: ${{ secrets.MVN_CENTRAL_USERNAME }}
MVN_CENTRAL_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }}

- name: Push tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: ${{ env.TAG_NAME }}

- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.TAG_NAME }}
generate_release_notes: true
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bump_project_version:
./scripts/bump_project_version.sh $(NEW_VERSION)
28 changes: 28 additions & 0 deletions scripts/bump_project_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Check if new_version argument is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <new_version>"
exit 1
fi

# Assign the new_version argument to a variable
new_version="$1"
commit_message="chore: bump project version to $new_version"
branch_name="bump/v$new_version"

# Checkout master branch and pull
git checkout master
git pull

# Bump project version
mvn versions:set -DgenerateBackupPoms=false -DnewVersion="$new_version"

# Commit & push changes
git checkout -b "$branch_name"
git add pom.xml
git commit -m "$commit_message"
git push origin "$branch_name"

# Create pull request
gh pr create --title "spring-search-$new_version" --body "Automated PR for project version bump" --base master --head "$branch_name"

0 comments on commit 62477f3

Please sign in to comment.