Publish SDK package #128
Workflow file for this run
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
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 or java sdk | |
- name: Set publish target | |
id: publish_target | |
run: | | |
echo "PUBLISH_ALL_TARGET=true" >> "$GITHUB_OUTPUT" | |
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT" | |
if [[ ${{ github.event.release.tag_name }} == *"python-sdk"* ]]; then | |
echo "PUBLISH_ALL_TARGET=false" >> "$GITHUB_OUTPUT" | |
elif [[ ${{ github.event.release.tag_name }} == *"java-sdk"* ]]; then | |
echo "PUBLISH_ALL_TARGET=false" >> "$GITHUB_OUTPUT" | |
- name: Get the version | |
id: get_sdk_version | |
run: | | |
echo "AVI_VERSION=$(python ./python/version.py)" >> "$GITHUB_OUTPUT" | |
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 "JAVA_RELEASE_VERSION=${JAVA_VERSION}" >> "$GITHUB_OUTPUT" | |
- if: steps.publish_target.outputs.PUBLISH_ALL_TARGET == 'true' || contains(steps.publish_target.outputs.TAG_NAME, 'java-sdk') | |
name: Publish JAVA Packages | |
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 --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') | |
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 | |
./create_sdk_pkgs.sh | |
./create_sdk_pip_packages.sh sdk | |
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." | |
./create_sdk_pypi.sh sdk | |
fi | |
echo "AVI VERSION=== $AVI_VERSION" | |
ls dist/ | |
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 | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }} | |
TWINE_REPOSITORY: pypi | |
- name: update release | |
id: update_release | |
uses: tubone24/update_release@v1.0 | |
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 | |
#- 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 | |