Skip to content

Commit

Permalink
Update release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhachane authored and mkhachane committed May 8, 2024
1 parent ca73d2a commit e395e65
Showing 1 changed file with 50 additions and 19 deletions.
69 changes: 50 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,27 @@ jobs:
- uses: actions/setup-python@v2
with:
python-version: 3.8
# Set publish target as either of all targets, python sdk or java sdk

# Set publish target as either of all targets, python sdk, java sdk or migration tools
- 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"
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 "AVI_VERSION=$(python ./python/version.py)" >> "$GITHUB_OUTPUT"
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"
Expand All @@ -56,10 +61,10 @@ jobs:
JAVA_VERSION=$JAVA_VERSION.RELEASE
fi
echo "Java version ${JAVA_VERSION}"
echo "JAVA_RELEASE_VERSION=${JAVA_VERSION}" >> "$GITHUB_OUTPUT"
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 Packages
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 }}"
Expand All @@ -70,6 +75,7 @@ jobs:
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 ..
Expand All @@ -79,7 +85,7 @@ jobs:
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')
- 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`
Expand All @@ -93,19 +99,34 @@ jobs:
# 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.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."
./create_sdk_pypi.sh sdk
if [[ ${{ steps.publish_target.outputs.PUBLISH_ALL_TARGET }} == true ]] || [[ ${{ steps.publish_target.outputs.PUBLISH_SDK_TARGET }} == true ]]; then
./create_sdk_pkgs.sh
./create_sdk_pypi.sh sdk
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/
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
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 }}
Expand All @@ -128,6 +149,17 @@ jobs:
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:
Expand Down Expand Up @@ -181,4 +213,3 @@ jobs:
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

0 comments on commit e395e65

Please sign in to comment.