-
Notifications
You must be signed in to change notification settings - Fork 71
216 lines (200 loc) · 11.1 KB
/
release.yml
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Publish SDK package
# Controls when the action will run.
on:
release:
types: [created]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-22.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v2
- name: Set up Maven Central Repository
uses: actions/setup-java@v1
with:
java-version: 11
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
# Sets up python3
- uses: actions/setup-python@v2
with:
python-version: 3.8
# Set publish target as either of all targets, python sdk, java sdk or migration tools
- name: Set publish target
id: publish_target
run: |
echo "::set-output name=PUBLISH_ALL_TARGET::true"
echo "::set-output name=TAG_NAME::${{ github.event.release.tag_name }}"
echo "::set-output name=PUBLISH_MIGRATION_TARGET::true"
echo "::set-output name=PUBLISH_SDK_TARGET::true"
if [[ ${{ github.event.release.tag_name }} == *"migration-tool"* ]]; then
echo "::set-output name=PUBLISH_SDK_TARGET::false"
echo "::set-output name=PUBLISH_ALL_TARGET::false"
elif [[ ${{ github.event.release.tag_name }} == *"java-sdk"* ]] || [[ ${{ github.event.release.tag_name }} == *"python-sdk"* ]]; then
echo "::set-output name=PUBLISH_MIGRATION_TARGET::false"
echo "::set-output name=PUBLISH_ALL_TARGET::false"
fi
- name: Get the version
id: get_sdk_version
run: |
echo "::set-output name=AVI_VERSION::$(python ./python/version.py)"
JAVA_VERSION=$(echo ${GITHUB_REF##*/} | cut -d - -f 2)
if [[ "$JAVA_VERSION" == *"post"* ]]; then
echo "Java version post"
JAVA_VERSION="${JAVA_VERSION/post/\.}"
elif [[ "$JAVA_VERSION" == *"b"* ]]; then
echo "Java version beta:"
JAVA_VERSION="${JAVA_VERSION/b/-beta-}"
else
echo "Java version Release"
JAVA_VERSION=$JAVA_VERSION.RELEASE
fi
echo "Java version ${JAVA_VERSION}"
echo "::set-output name=JAVA_RELEASE_VERSION::${JAVA_VERSION}"
# - if: steps.publish_target.outputs.PUBLISH_ALL_TARGET == 'true' || contains(steps.publish_target.outputs.TAG_NAME, 'java-sdk')
# name: Publish JAVA
# run: |
# echo "Publish Java Version ${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}"
# echo "Publish AVI VERSION ${{ steps.get_sdk_version.outputs.AVI_VERSION }}"
# cd java
# mvn versions:set -DnewVersion=${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}
# if [[ ${{ steps.publish_target.outputs.TAG_NAME }} == "test-"* ]]; then
# echo "Test tag found. Skipping java assets upload to public repo."
# mvn clean install -Dgpg.skip=true
# else
# echo "Normal tag found. Uploading java assets to public repo."
# # mvn clean install -Dgpg.skip=true
# mvn clean --batch-mode deploy -DskipTests -Dgpg.passphrase=${{ secrets.AVISDK_PGP_PASSPHRASE }} -Denv.MAVEN_USERNAME=${{ secrets.OSSRH_USERNAME }} -Denv.MAVEN_PASSWORD=${{ secrets.OSSRH_TOKEN }}
# fi
# cd ..
# ls java/target/
# cp java/target/avisdk-${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}.jar .
# cp java/target/avisdk-${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}-javadoc.jar .
# cp java/target/avisdk-${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}-sources.jar .
# Installs and upgrades pip, installs other dependencies and installs the package from setup.py
- if: steps.publish_target.outputs.PUBLISH_ALL_TARGET == 'true' || contains(steps.publish_target.outputs.TAG_NAME, 'python-sdk') || steps.publish_target.outputs.PUBLISH_MIGRATION_TARGET == 'true'
name: "Installs and upgrades pip, installs other dependencies and installs the package from setup.py"
run: |
AVI_VERSION=`python ./python/version.py`
# Upgrade pip
python3 -m pip install --upgrade pip
# Install build deps
python3 -m pip install wheel twine setuptools==47.1.1
sudo apt-get install debhelper
sudo apt-get install python-all
sudo apt-get install python3-all
# If requirements.txt exists, install from it
cd python
mkdir dist
if [[ ${{ steps.publish_target.outputs.PUBLISH_ALL_TARGET }} == true ]] || [[ ${{ steps.publish_target.outputs.PUBLISH_SDK_TARGET }} == true ]]; then
./create_sdk_pip_packages.sh sdk
fi
if [[ ${{ steps.publish_target.outputs.PUBLISH_ALL_TARGET }} == true ]] || [[ ${{ steps.publish_target.outputs.PUBLISH_MIGRATION_TARGET }} == true ]]; then
./create_sdk_pip_packages.sh migrationtools
fi
if [[ ${{ steps.publish_target.outputs.TAG_NAME }} == "test-"* ]]; then
echo "Test tag found. Skipping python assets upload to public repo."
else
echo "Normal tag found. Uploading python assets to public repo."
if [[ ${{ steps.publish_target.outputs.PUBLISH_ALL_TARGET }} == true ]] || [[ ${{ steps.publish_target.outputs.PUBLISH_SDK_TARGET }} == true ]]; then
./create_sdk_pypi.sh sdk
./create_sdk_pkgs.sh
fi
if [[ ${{ steps.publish_target.outputs.PUBLISH_ALL_TARGET }} == true ]] || [[ ${{ steps.publish_target.outputs.PUBLISH_MIGRATION_TARGET }} == true ]]; then
./create_sdk_pypi.sh migrationtools
fi
fi
echo "AVI VERSION=== $AVI_VERSION"
ls dist/
if [[ ${{ steps.publish_target.outputs.PUBLISH_ALL_TARGET }} == true ]] || [[ ${{ steps.publish_target.outputs.PUBLISH_MIGRATION_TARGET }} == true ]]; then
mv dist/avimigrationtools-$AVI_VERSION.tar.gz ../avimigrationtools-$AVI_VERSION.tar.gz
fi
if [[ ${{ steps.publish_target.outputs.PUBLISH_ALL_TARGET }} == true ]] || [[ ${{ steps.publish_target.outputs.PUBLISH_SDK_TARGET }} == true ]]; then
mv dist/avisdk-$AVI_VERSION.tar.gz ../avisdk-$AVI_VERSION.tar.gz
#mv dist/python-avisdk_0_all.deb ../avisdk-$AVI_VERSION.deb
mv dist/avisdk-$AVI_VERSION-1.noarch.rpm ../avisdk-$AVI_VERSION.rpm
fi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }}
TWINE_REPOSITORY: pypi
- name: update release
id: update_release
uses: tubone24/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
- if: steps.publish_target.outputs.PUBLISH_ALL_TARGET == 'true' || contains(steps.publish_target.outputs.TAG_NAME, 'python-sdk')
name: Upload Avi API SDK pip package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
upload_url: ${{ steps.update_release.outputs.upload_url }}
asset_path: avisdk-${{ steps.get_sdk_version.outputs.AVI_VERSION }}.tar.gz
asset_name: pip-package-avisdk-${{ steps.get_sdk_version.outputs.AVI_VERSION }}.tar.gz
asset_content_type: application/gzip
- if: steps.publish_target.outputs.PUBLISH_ALL_TARGET == 'true' || steps.publish_target.outputs.PUBLISH_MIGRATION_TARGET == 'true'
name: Upload Avi Migration Tools pip package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
upload_url: ${{ steps.update_release.outputs.upload_url }}
asset_path: avimigrationtools-${{ steps.get_sdk_version.outputs.AVI_VERSION }}.tar.gz
asset_name: pip-package-avimigrationtools-${{ steps.get_sdk_version.outputs.AVI_VERSION }}.tar.gz
asset_content_type: application/gzip
#- name: Upload Avi API SDK debian package
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.github_token }}
# with:
# upload_url: ${{ steps.update_release.outputs.upload_url }}
# asset_path: avisdk-${{ steps.get_sdk_version.outputs.AVI_VERSION }}.deb
# asset_name: debian-package-avisdk-${{ steps.get_sdk_version.outputs.AVI_VERSION }}
# asset_content_type: application/vnd.debian.binary-package
- if: steps.publish_target.outputs.PUBLISH_ALL_TARGET == 'true' || contains(steps.publish_target.outputs.TAG_NAME, 'python-sdk')
name: Upload Avi API SDK rpm package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
upload_url: ${{ steps.update_release.outputs.upload_url }}
asset_path: avisdk-${{ steps.get_sdk_version.outputs.AVI_VERSION }}.rpm
asset_name: rpm--package-avisdk-${{ steps.get_sdk_version.outputs.AVI_VERSION }}.rpm
asset_content_type: application/x-rpm
- if: steps.publish_target.outputs.PUBLISH_ALL_TARGET == 'true' || contains(steps.publish_target.outputs.TAG_NAME, 'java-sdk')
name: Upload Avi API SDK Java package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
upload_url: ${{ steps.update_release.outputs.upload_url }}
asset_path: avisdk-${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}.jar
asset_name: Java-avisdk-${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}.jar
asset_content_type: application/java-archive
- if: steps.publish_target.outputs.PUBLISH_ALL_TARGET == 'true' || contains(steps.publish_target.outputs.TAG_NAME, 'java-sdk')
name: Upload Avi API SDK Javadoc package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
upload_url: ${{ steps.update_release.outputs.upload_url }}
asset_path: avisdk-${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}-javadoc.jar
asset_name: Java-avisdk-${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}-javadoc.jar
asset_content_type: application/java-archive
- if: steps.publish_target.outputs.PUBLISH_ALL_TARGET == 'true' || contains(steps.publish_target.outputs.TAG_NAME, 'java-sdk')
name: Upload Avi API SDK Java sources package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
upload_url: ${{ steps.update_release.outputs.upload_url }}
asset_path: avisdk-${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}-sources.jar
asset_name: Java-avisdk-${{ steps.get_sdk_version.outputs.JAVA_RELEASE_VERSION }}-javasources.jar
asset_content_type: application/java-archive