-
Notifications
You must be signed in to change notification settings - Fork 3
156 lines (131 loc) · 5.1 KB
/
doc_and_library_release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: NS Messaging library Release and AsyncAPI documents processing
on:
push:
tags:
- 'v*'
jobs:
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: Set version in README example
run: |
echo "${{ github.event.inputs.version }}"
sed -i "s/implementation 'com.craxiom:network-survey-messaging:[^\"]*\'/implementation 'com.craxiom:network-survey-messaging:${{ env.VERSION_NAME }}\'/g" README.md
- 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 .
# Check for changes
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "Bump version to ${{ env.VERSION_NAME }}"
git push origin develop
fi
generateDocs:
needs: setVersion
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
ref: develop
- name: Validating AsyncAPI document
uses: asyncapi/[email protected]
with:
command: validate
filepath: src/main/asyncapi/network_survey_messaging.yaml
- name: Generating HTML from my AsyncAPI document
uses: asyncapi/[email protected]
with:
template: '@asyncapi/[email protected]' #In case of template from npm, because of @ it must be in quotes
filepath: src/main/asyncapi/network_survey_messaging.yaml
output: generated-html
#Using another action that takes generated HTML and pushes it to GH Pages
- name: Deploy GH page
uses: JamesIves/github-pages-deploy-action@v4
with:
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: Add Gradle Credentials
env:
GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: |
./gradlew addCredentials --key sonatypeUsername --value $SONATYPE_USERNAME
./gradlew addCredentials --key sonatypePassword --value $SONATYPE_PASSWORD
./gradlew addCredentials --key sonatypeKeyPassword --value $GPG_KEY_PASSWORD
- name: Create gradle.properties
env:
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
run: |
echo "signing.keyId=$GPG_KEY_ID" >> gradle.properties
echo "signing.secretKeyRingFile=$(pwd)/sonatype-secret-keys.gpg" >> gradle.properties
- name: Build and Publish 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
- name: Create a Release in GitHub
uses: ncipollo/release-action@v1
with:
artifacts: "build/libs/*.jar"
tag: ${{ steps.version.outputs.content }}
commit: ${{ github.sha }}
generateReleaseNotes: true
draft: false