-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Vladimir Djurovic <vdjurovic@bitshifted.co>
- Loading branch information
Showing
3 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Release new version to Maven Central | ||
on: | ||
push: | ||
branches: [main] | ||
jobs: | ||
release-maven-central: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Configure Git user | ||
run: | | ||
git config user.email "actions@github.com" | ||
git config user.name "GitHub Actions" | ||
- name: Import GPG signing key | ||
uses: crazy-max/ghaction-import-gpg@v5 | ||
with: | ||
gpg_private_key: ${{ secrets.MAVEN_SIGNING_KEY }} | ||
passphrase: ${{ secrets.MAVEN_SIGNING_KEY_PASSPHRASE }} | ||
- name: Setup SSH | ||
run: | | ||
echo "Setting up SSH..." | ||
mkdir ~/.ssh | ||
echo "$SSH_KEY" > ~/.ssh/appforge-key | ||
chmod 600 ~/.ssh/appforge-key | ||
cat <<EOF > ~/.ssh/config | ||
Host github.com | ||
User git | ||
IdentityFile ~/.ssh/appforge-key | ||
ForwardAgent yes | ||
EOF | ||
cat ~/.ssh/config | ||
echo "Starting SSH agent" | ||
eval "$(ssh-agent -s)" | ||
ssh-add ~/.ssh/appforge-key | ||
shell: bash | ||
env: | ||
SSH_KEY: ${{ secrets.APPFORGE_DEPLOY_PRIV_KEY }} | ||
- name: Install JDK | ||
uses: actions/setup-java@v3 | ||
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: | | ||
export VERSION=$(./cicd/version.sh) | ||
echo "Version to set: $VERSION" | ||
echo "TAG_NAME=$VERSION" >> $GITHUB_ENV | ||
mvn -P release -Dgpg.keyname=${{ secrets.GPG_KEY_NAME }} -Dgpg.passphrase=${{ secrets.MAVEN_SIGNING_KEY_PASSPHRASE }} \ | ||
-Drevision=$VERSION deploy | ||
env: | ||
MVN_CENTRAL_USERNAME: ${{ vars.MVN_CENTRAL_USERNAME }} | ||
MVN_CENTRAL_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }} | ||
- name: Tag version | ||
run: | | ||
git tag v${{ env.TAG_NAME }} | ||
git push origin --tags | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#! /bin/bash | ||
# | ||
# /* | ||
# * Copyright (c) 2023 Bitshift D.O.O (http://bitshifted.co) | ||
# * | ||
# * This Source Code Form is subject to the terms of the Mozilla Public | ||
# * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# */ | ||
# | ||
|
||
# Parse command line options. | ||
|
||
while getopts ":Mmp" Option | ||
do | ||
case $Option in | ||
M ) major=true;; | ||
m ) minor=true;; | ||
p ) patch=true;; | ||
esac | ||
done | ||
|
||
shift $(($OPTIND - 1)) | ||
|
||
version=$1 | ||
|
||
# Build array from version string. | ||
|
||
a=( ${version//./ } ) | ||
|
||
# If version string is missing or has the wrong number of members, show usage message. | ||
|
||
if [ ${#a[@]} -ne 3 ] | ||
then | ||
echo "usage: $(basename $0) [-Mmp] major.minor.patch" | ||
exit 1 | ||
fi | ||
|
||
# Increment version numbers as requested. | ||
|
||
if [ ! -z $major ] | ||
then | ||
((a[0]++)) | ||
a[1]=0 | ||
a[2]=0 | ||
fi | ||
|
||
if [ ! -z $minor ] | ||
then | ||
((a[1]++)) | ||
a[2]=0 | ||
fi | ||
|
||
if [ ! -z $patch ] | ||
then | ||
((a[2]++)) | ||
fi | ||
|
||
echo "${a[0]}.${a[1]}.${a[2]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#! /bin/bash | ||
# | ||
# /* | ||
# * Copyright (c) 2023 Bitshift D.O.O (http://bitshifted.co) | ||
# * | ||
# * This Source Code Form is subject to the terms of the Mozilla Public | ||
# * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# */ | ||
# | ||
|
||
PATCH_REGEX='^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)\s?(\(.+\))?\s?:\s*(.+)' | ||
MINOR_REGEX='^(feat)\s*(\(.+\))?\s?:\s*(.+)' | ||
MAJOR_REGEX='^(BREAKING CHANGE)\s*(\(.+\))?\s?:\s*(.+)' | ||
|
||
# get the latest tag | ||
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` 2> /dev/null) | ||
if [ -z $LATEST_TAG ]; then | ||
LATEST_TAG="v1.0.0" | ||
echo "1.0.0" | ||
exit 0 | ||
fi | ||
|
||
LATEST_VERSION="" | ||
if [[ $LATEST_TAG =~ [0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
LATEST_VERSION=${BASH_REMATCH[0]} | ||
else | ||
echo "Failed to extract current version" >&2 | ||
exit 1 | ||
fi | ||
|
||
SCRIPT_DIR=$( dirname -- "$0"; ) | ||
# process last commit message | ||
MESSAGE=$(git log -1 --pretty=%B) | ||
if [[ "$MESSAGE" =~ $PATCH_REGEX ]]; then | ||
"$SCRIPT_DIR"/semver-bump.sh -p $LATEST_VERSION | ||
elif [[ "$MESSAGE" =~ $MINOR_REGEX ]]; then | ||
"$SCRIPT_DIR"/semver-bump.sh -m $LATEST_VERSION | ||
elif [[ $MESSAGE =~ $MAJOR_REGEX ]]; then | ||
"$SCRIPT_DIR"/semver-bump.sh -M $LATEST_VERSION | ||
else | ||
"$SCRIPT_DIR"/semver-bump.sh -p $LATEST_VERSION | ||
fi | ||
|
||
|
||
|
||
|