diff --git a/.github/workflows/hidrive-next-build.yml b/.github/workflows/hidrive-next-build.yml index 2db0bab8b92b9..207972ef05527 100644 --- a/.github/workflows/hidrive-next-build.yml +++ b/.github/workflows/hidrive-next-build.yml @@ -28,16 +28,14 @@ on: - '**.vue' push: branches: - - main - - master - - stable* - ionos-dev - - ionos-dev30 + - ionos-stable env: TARGET_PACKAGE_NAME: hidrive-next.zip REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} + ARTIFACTORY_REPOSITORY_SNAPSHOT: ionos-productivity-hdnext-snapshot permissions: contents: read @@ -48,7 +46,9 @@ jobs: permissions: contents: read - packages: write + + outputs: + NC_VERSION: ${{ steps.get_nc_version.outputs.NC_VERSION }} name: hidrive-next-build steps: @@ -118,10 +118,24 @@ jobs: - name: Zip dependencies run: make -f IONOS/Makefile zip_dependencies TARGET_PACKAGE_NAME=${{ env.TARGET_PACKAGE_NAME }} + - name: Get NC version + id: get_nc_version + run: | + NC_VERSION=$(jq -r '.ncVersion' version.json) + echo "NC_VERSION: $NC_VERSION" + + if [ -z "$NC_VERSION" ]; then + echo "NC_VERSION is empty" + exit 1 + fi + + echo "NC_VERSION=$NC_VERSION" >> $GITHUB_OUTPUT + - name: Upload artifact result for job hidrive-next-build uses: actions/upload-artifact@v4 with: - name: hidrive_next_build_zip + retention-days: 30 + name: hidrive_next_build_artifact path: ${{ env.TARGET_PACKAGE_NAME }} - name: Show changes on failure @@ -131,6 +145,70 @@ jobs: git --no-pager diff exit 1 # make it red to grab attention + upload-to-artifactory: + runs-on: self-hosted + # Upload the artifact to the Artifactory repository on PR *OR* on "ionos-dev|ionos-stable" branch push defined in the on:push:branches + if: github.event_name == 'pull_request' || github.ref_name == 'ionos-dev' || github.ref_name == 'ionos-stable' + + name: Push artifact to artifactory as dev build + needs: hidrive-next-build + + env: + BUILD_NAME: "hidrive_next-snapshot" + + steps: + - name: Download artifact zip + uses: actions/download-artifact@v4 + with: + name: hidrive_next_build_artifact + + # This action sets up the JFrog CLI with the Artifactory URL and access token + - uses: jfrog/setup-jfrog-cli@v4 + env: + JF_URL: ${{ secrets.JF_ARTIFACTORY_URL }} + JF_USER: ${{ secrets.JF_ARTIFACTORY_USER }} + JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }} + + - name: Ping the JF server + run: | + # Ping the server + jf rt ping + + - name: Upload build to artifactory + run: | + # PR builds are stored in a separate directory as "dev/pr/hidrive-next-pr-.zip" + # Push to "ionos-dev" branch is stored as "dev/hidrive-next-.zip" + + ARTIFACTORY_STAGE_PREFIX="dev" + + # set ARTIFACTORY_STAGE_PREFIX=stable on ionos-stable branch + if [ "${{ github.ref_name }}" == "ionos-stable" ]; then + ARTIFACTORY_STAGE_PREFIX="stable" + fi + + export PATH_TO_DIRECTORY="${{ env.ARTIFACTORY_REPOSITORY_SNAPSHOT }}/${ARTIFACTORY_STAGE_PREFIX}" + PATH_TO_FILE="pr/hidrive-next-pr-${{ github.event.pull_request.number }}.zip" + + if [ -z "${{ github.event.pull_request.number }}" ]; then + PATH_TO_FILE="hidrive-next-${{ needs.hidrive-next-build.outputs.NC_VERSION }}.zip" + fi + + export PATH_TO_LATEST_ARTIFACT="${PATH_TO_DIRECTORY}/${PATH_TO_FILE}" + + # Promote current build to the "latest" dev build + jf rt upload "${{ env.TARGET_PACKAGE_NAME }}" \ + --build-name "${{ env.BUILD_NAME }}" \ + --build-number ${{ github.run_number }} \ + --target-props "hdnext.nc_version=${{ needs.hidrive-next-build.outputs.NC_VERSION }};vcs.branch=${{ github.ref }};vcs.revision=${{ github.sha }}" \ + $PATH_TO_LATEST_ARTIFACT + + - name: Show changes on failure + if: failure() + run: | + git status + git --no-pager diff + exit 1 # make it red to grab attention + hidirve-next-artifact-to-ghcr_io: runs-on: ubuntu-latest @@ -145,7 +223,7 @@ jobs: - name: Download artifact zip uses: actions/download-artifact@v4 with: - name: hidrive_next_build_zip + name: hidrive_next_build_artifact - name: Log in to the Container registry uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1