Skip to content

Commit

Permalink
Update release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mkhachane authored May 8, 2024
1 parent c4660fe commit ca73d2a
Showing 1 changed file with 19 additions and 43 deletions.
62 changes: 19 additions & 43 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-18.04
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: 1.8
java-version: 11
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
Expand All @@ -28,27 +28,22 @@ jobs:
- 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
# Set publish target as either of all targets, python sdk or java sdk
- 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 }}"
if [[ ${{ github.event.release.tag_name }} == *"migration-tool"* ]]; then
echo "::set-output name=PUBLISH_MIGRATION_TARGET::true"
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_SDK_TARGET::true"
echo "::set-output name=PUBLISH_ALL_TARGET::false"
fi
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 "::set-output name=AVI_VERSION::$(python ./python/version.py)"
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"
Expand All @@ -61,10 +56,10 @@ jobs:
JAVA_VERSION=$JAVA_VERSION.RELEASE
fi
echo "Java version ${JAVA_VERSION}"
echo "::set-output name=JAVA_RELEASE_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
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 }}"
Expand All @@ -84,7 +79,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') || steps.publish_target.outputs.PUBLISH_MIGRATION_TARGET == 'true'
- 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`
Expand All @@ -98,27 +93,19 @@ jobs:
# 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
elif [[ ${{ steps.publish_target.outputs.PUBLISH_ALL_TARGET }} == true ]] || [[ ${{ steps.publish_target.outputs.PUBLISH_MIGRATION_TARGET }} == true ]]; then
./create_sdk_pip_packages.sh migrationtools
fi
./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
./create_sdk_pkgs.sh
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
elif [[ ${{ 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
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 }}
Expand All @@ -141,17 +128,6 @@ 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

0 comments on commit ca73d2a

Please sign in to comment.