Skip to content

Commit

Permalink
github actions now handle release
Browse files Browse the repository at this point in the history
  • Loading branch information
Tushar-Naik committed Nov 11, 2022
1 parent 3d4c83f commit 29b5385
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 10 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,31 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: "👷 Checkout code"
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up java

- name: "☕ Set up java"
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
cache: maven
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Compile

- name: "🔧 Compile"
run: mvn compile
- name: Cache SonarCloud packages

- name: "⏬ Cache SonarCloud packages"
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Quality Check

- name: "🎓 Quality Check"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
97 changes: 93 additions & 4 deletions .github/workflows/manual-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,113 @@ name: Manual Deployment to Maven Central
on: workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: "👷 Checkout code"
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "☕ Set up java"
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: maven
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: "🔧 Compile"
run: mvn compile

publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- name: "👷 Checkout code"
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "☕ Set up java"
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
cache: maven
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish package

- name: "🗽 Publish package"
run: mvn clean deploy -DskipTests -Prelease
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

tag_release:
needs: publish
runs-on: ubuntu-latest
steps:
- name: "👷 Checkout code"
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: "📎 Install xmllint"
run: sudo apt-get install -y libxml2-utils

- name: "📑 Setup release information"
run: |
pom_version=`xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml`
echo "POM_VERSION=$pom_version" >> $GITHUB_ENV
- name: "✏️ Generate release changelog"
id: extract-release-changelog
uses: heinrichreimer/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
unreleasedOnly: "true"
stripHeaders: "true"
stripGeneratorNotice: "true"
futureRelease: ${{ env.POM_VERSION }}

- name: "📍 Create release"
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.POM_VERSION }}
release_name: v${{ env.POM_VERSION }}
draft: false
prerelease: false
body: ${{ steps.extract-release-changelog.outputs.changelog }}

- name: "✏️ Generate full changelog"
id: extract-changelog
uses: heinrichreimer/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
stripGeneratorNotice: "true"

- name: "⛲ Commit files"
env:
CI_USER: github-actions
CI_EMAIL: [email protected]
run: |
git config --local user.email "$CI_EMAIL"
git config --local user.name "$CI_USER"
git status
git add CHANGELOG.md && git commit -m 'Updated CHANGELOG.md' && echo "push=true" >> $GITHUB_ENV || echo "No changes to CHANGELOG.md"
- name: "⏫ Push changes"
if: env.push == 'true'
env:
CI_USER: github-actions
CI_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push "https://$CI_USER:[email protected]/$GITHUB_REPOSITORY.git" HEAD:master

0 comments on commit 29b5385

Please sign in to comment.