Skip to content

Merge pull request #59 from nikanique/develop #25

Merge pull request #59 from nikanique/develop

Merge pull request #59 from nikanique/develop #25

Workflow file for this run

name: Build on Merge Workflow
on:
push:
branches:
- develop
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Maven cache
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Update Version for Develop
if: github.ref == 'refs/heads/develop'
run: mvn versions:set -DnewVersion=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-beta
- name: Build JAR
run: mvn clean package
- name: Archive Build Artifacts
uses: actions/upload-artifact@v3
with:
name: spring-rest-framework
path: target/*.jar
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Extract Version from pom.xml
id: version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
if [[ "${GITHUB_REF}" == "refs/heads/develop" ]]; then
VERSION="${VERSION}-beta"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: spring-rest-framework
path: ./artifact
- name: Create GitHub Release
env:
VERSION: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${VERSION}" ./artifact/*.jar \
--title "Release v${VERSION}" \
--notes "Automated release of version v${VERSION}"
publish:
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Update Version for Develop
if: github.ref == 'refs/heads/develop'
run: mvn versions:set -DnewVersion=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-beta
- name: Ensure GPG directory exists
run: |
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg
- name: Set GPG_TTY
run: echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
- name: Import GPG key
run: |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
echo "default-key $(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2)" >> ~/.gnupg/gpg.conf
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Configure GPG passphrase
run: echo "use-agent" >> ~/.gnupg/gpg.conf
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Publish to Maven Central
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
run: (echo "<settings><servers><server><id>central</id><username>$MAVEN_USERNAME</username><password>$MAVEN_PASSWORD</password></server></servers></settings>"> setting.xml) && mvn deploy -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} --settings setting.xml && rm setting.xml