-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the CI to build and publish a release artifact to Sonatype and…
… a GitHub release
- Loading branch information
1 parent
cd8b206
commit b941e4c
Showing
2 changed files
with
103 additions
and
3 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 |
---|---|---|
@@ -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: | ||
|
@@ -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 |
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