Skip to content

Commit

Permalink
Update the CI to build and publish a release artifact to Sonatype and…
Browse files Browse the repository at this point in the history
… a GitHub release
  • Loading branch information
christianrowlands committed Nov 15, 2023
1 parent cd8b206 commit b941e4c
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 3 deletions.
104 changes: 102 additions & 2 deletions .github/workflows/doc_generate.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,72 @@
name: AsyncAPI documents processing
name: NS Messaging library Release and AsyncAPI documents processing

on:
push:
tags:
- 'v*'

jobs:
generate:
setVersion:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: develop

- name: Extract version from tag
uses: damienaicheh/[email protected]

- name: Extract existing version code
run: |
# Set new version name from tag
if [[ -z "${{ env.PATCH }}" ]]; then
version_name=${{ env.MAJOR }}.${{ env.MINOR }}
else
version_name=${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }}
fi
# Set environment variable for later use
echo "VERSION_NAME=$version_name" >> $GITHUB_ENV
- name: Set version in build.gradle
run: |
# Update build.gradle with new version
echo "${{ env.VERSION_NAME }}"
sed -i "s/version \"[^\"]*\"/version \"${{ env.VERSION_NAME }}\"/g" build.gradle
- name: Install yq
uses: mikefarah/[email protected]

- name: Set openapi spec version to tag version using yq
run: |
echo "${{ env.VERSION_NAME }}"
yq e ".info.version = ${{ env.VERSION_NAME }}" -i src/main/asyncapi/network_survey_messaging.yaml
- name: Set version example to tag version using yq
run: |
echo "${{ env.VERSION_NAME }}"
yq e ".components.schemas.version.example = ${{ env.VERSION_NAME }}" -i src/main/asyncapi/network_survey_messaging.yaml
- name: Commit and push changes
run: |
git config user.email "[email protected]"
git config user.name "Github Actions"
git add .
git commit -am "Bump version to ${{ env.VERSION_NAME }}"
git push origin develop
generateDocs:
needs: setVersion
runs-on: ubuntu-latest
steps:
#Check out repo at the created tag
- name: Get tag name
id: get_tag_name
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Checkout repo
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -40,3 +94,49 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
branch: gh-pages
folder: generated-html


buildRelease:
needs: setVersion
runs-on: ubuntu-latest

steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
ref: develop

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'temurin'
cache: 'gradle'

- name: Save GPG Keys
env:
$GPG_FILE: ${{ secrets.GPG_FILE }}
run: echo $GPG_FILE | base64 -d > sonatype-secret-keys.gpg

- name: Build Release Artifacts
env:
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: ./gradlew clean build publish
-Dsigning.keyId=$GPG_KEY_ID
-Dsigning.secretKeyRingFile=$(pwd)/sonatype-secret-keys.gpg
-Dsigning.password=$GPG_KEY_PASSWORD
-DsonatypeUsername=$SONATYPE_USERNAME
-DsonatypePassword=$SONATYPE_PASSWORD

- name: Create a Release in GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "build/libs/*.jar"
token: ${{ secrets.GH_TOKEN }}
tag: ${{ steps.version.outputs.content }}
commit: ${{ github.sha }}
generateReleaseNotes: true
draft: true
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ plugins {
}

group 'com.craxiom'
version '0.13.1'
version "0.14.0-SNAP"

// Configure the wrapper and ALL distro so IJ has additional context
wrapper {
Expand Down

0 comments on commit b941e4c

Please sign in to comment.