Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add deploy workflow #89

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"