diff --git a/.github/workflows/npm_publish_light.yml b/.github/workflows/npm_publish_light.yml index 6305cbf1..2496cb80 100644 --- a/.github/workflows/npm_publish_light.yml +++ b/.github/workflows/npm_publish_light.yml @@ -13,6 +13,8 @@ env: SDK_JS_PACKAGE_NAME: "@kindredgroup/cohort_sdk_js" SDK_CLIENT_PACKAGE_NAME: "@kindredgroup/cohort_sdk_client" REGISTRY: "https://npm.pkg.github.com" + API_URL: "https://api.github.com/orgs/kindredgroup/packages/npm" + API_VERSION: "2022-11-28" jobs: npm: strategy: @@ -130,16 +132,38 @@ jobs: echo "Current version is" npm version echo "Unpublishing faulty version" - echo "D: npm unpublish $SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION" - npm unpublish "$SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION" --registry $REGISTRY + all_versions_sdk_client_js=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $NODE_AUTH_TOKEN -H "X-GitHub-Api-Version: $API_VERSION" "$API_URL/cohort_sdk_client/versions") + lookup_package_version_id=$(echo $all_versions_sdk_client_js | yq '.[] | select(.name=="$SDK_JS_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION") | .id') + if [ "$lookup_package_version_id" == "" ]; + then + echo "Unable to find package version id" + exit 1 + else + echo "Deleting all_versions_sdk_client_js $lookup_package_version_id of $SDK_JS_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION" + curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $NODE_AUTH_TOKEN" -H "X-GitHub-Api-Version: $API_VERSION" "$API_URL/cohort_sdk_client/versions/$lookup_package_version_id" + fi + unset all_versions_sdk_client_js + unset lookup_package_version_id + echo "Done deleting SDK client version" cd ${{ matrix.settings.dirSdkJs }} pwd ls -l echo "Current version is" npm version echo "Unpublishing faulty version" - echo "D: npm unpublish $SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION" - npm unpublish "$SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION" --registry $REGISTRY + all_versions_sdk_js=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $NODE_AUTH_TOKEN -H "X-GitHub-Api-Version: $API_VERSION" "$API_URL/cohort_sdk_js/versions") + lookup_package_version_id=$(echo $all_versions_sdk_js | yq '.[] | select(.name=="$SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION") | .id') + if [ "$lookup_package_version_id" == "" ]; + then + echo "Unable to find package version id" + exit 1 + else + echo "Deleting cohort_sdk_js $lookup_package_version_id of $SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION" + curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $NODE_AUTH_TOKEN" -H "X-GitHub-Api-Version: $API_VERSION" "$API_URL/cohort_sdk_js/versions/$lookup_package_version_id" + fi + unset all_versions_sdk_client_js + unset lookup_package_version_id + echo "Done deleting SDK client JS version" - name: Build ${{ matrix.settings.dirCohortReplicator }} env: @@ -170,13 +194,35 @@ jobs: echo "Current version is" npm version echo "Unpublishing faulty version" - echo "D: npm unpublish $SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION" - npm unpublish "$SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION" --registry $REGISTRY + all_versions_sdk_client_js=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $NODE_AUTH_TOKEN -H "X-GitHub-Api-Version: $API_VERSION" "$API_URL/cohort_sdk_client/versions") + lookup_package_version_id=$(echo $all_versions_sdk_client_js | yq '.[] | select(.name=="$SDK_JS_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION") | .id') + if [ "$lookup_package_version_id" == "" ]; + then + echo "Unable to find package version id" + exit 1 + else + echo "Deleting all_versions_sdk_client_js $lookup_package_version_id of $SDK_JS_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION" + curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $NODE_AUTH_TOKEN" -H "X-GitHub-Api-Version: $API_VERSION" "$API_URL/cohort_sdk_client/versions/$lookup_package_version_id" + fi + unset all_versions_sdk_client_js + unset lookup_package_version_id + echo "Done deleting SDK client version" cd ${{ matrix.settings.dirSdkJs }} pwd ls -l echo "Current version is" npm version echo "Unpublishing faulty version" - echo "D: npm unpublish $SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION" - npm unpublish "$SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION" --registry $REGISTRY \ No newline at end of file + all_versions_sdk_js=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $NODE_AUTH_TOKEN -H "X-GitHub-Api-Version: $API_VERSION" "$API_URL/cohort_sdk_js/versions") + lookup_package_version_id=$(echo $all_versions_sdk_js | yq '.[] | select(.name=="$SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION") | .id') + if [ "$lookup_package_version_id" == "" ]; + then + echo "Unable to find package version id" + exit 1 + else + echo "Deleting cohort_sdk_js $lookup_package_version_id of $SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION" + curl -L -X DELETE -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $NODE_AUTH_TOKEN" -H "X-GitHub-Api-Version: $API_VERSION" "$API_URL/cohort_sdk_js/versions/$lookup_package_version_id" + fi + unset all_versions_sdk_client_js + unset lookup_package_version_id + echo "Done deleting SDK client JS version" \ No newline at end of file