feat: Simulate failure and try uninstall step #65
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
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
# Creates and publishes @kindredgroup/cohort_sdk_js, @kindredgroup/cohort_sdk_client | |
# NPM packages. The "cohort_sdk_js" is bundled together with Talos sources so that users | |
# could build it locally. | |
# Performs a basic build test by installing "cohort_sdk_client" into | |
# "cohort_banking_initiator_js", "cohort_banking_replicator_js" apps and then builds apps. | |
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
name: Build and Publish Cohort SDK NPMs | |
on: | |
# workflow_call: | |
push: | |
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: | |
fail-fast: false | |
matrix: | |
settings: | |
- host: macos-latest | |
dirSdkJs: packages/cohort_sdk_js | |
dirSdkJsClient: cohort_sdk_client | |
dirCohortInitiator: cohort_banking_initiator_js | |
dirCohortReplicator: cohort_banking_replicator_js | |
name: Publish SDK NPS with bundled Rust for node@16 | |
runs-on: ${{ matrix.settings.host }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
check-latest: true | |
registry-url: "https://npm.pkg.github.com" | |
- name: Customise host image | |
shell: bash | |
run: |- | |
echo "NPM_CONFIG_USERCONFIG=$NPM_CONFIG_USERCONFIG" | |
cat $NPM_CONFIG_USERCONFIG | |
echo "" | |
- name: Setup version for ${{ matrix.settings.dirSdkJs }} NPM | |
id: sdk-js-version | |
shell: bash | |
run: |- | |
echo "Building SDK JS Library" | |
cd ${{ matrix.settings.dirSdkJs }} | |
pwd | |
ls -l | |
npm ci --foreground-scripts | |
../../scripts/github-actions-ci/set-npm-dev-version.sh ${{ env.SDK_JS_PACKAGE_NAME }} "SDK_JS_PACKAGE_VERSION" | |
echo "" | |
- name: Build and Publish ${{ matrix.settings.dirSdkJs }} | |
shell: bash | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: |- | |
cd ${{ matrix.settings.dirSdkJs }} | |
pwd | |
ls -l | |
echo "Current version is" | |
npm version | |
npm publish --foreground-scripts | |
echo "" | |
- name: Setup version for ${{ matrix.settings.dirSdkJsClient }} NPM | |
id: sdk-client-version | |
shell: bash | |
env: | |
SDK_JS_PACKAGE_VERSION: ${{ steps.sdk-js-version.outputs.SDK_JS_PACKAGE_VERSION }} | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: |- | |
echo "Building SDK Client" | |
cd ${{ matrix.settings.dirSdkJsClient }} | |
pwd | |
ls -lah | |
rm package-lock.json || true | |
echo "D: npm install $SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION --foreground-scripts" | |
npm install "$SDK_JS_PACKAGE_NAME@$SDK_JS_PACKAGE_VERSION" --foreground-scripts | |
../scripts/github-actions-ci/set-npm-dev-version.sh ${{ env.SDK_CLIENT_PACKAGE_NAME }} "SDK_CLIENT_PACKAGE_VERSION" | |
echo "" | |
- name: Build and Publish ${{ matrix.settings.dirSdkJsClient }} NPM | |
shell: bash | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: |- | |
cd ${{ matrix.settings.dirSdkJsClient }} | |
pwd | |
ls -l | |
echo "Current version is" | |
npm version | |
npm ci --foreground-scripts | |
npm run build --foreground-scripts | |
npm publish --foreground-scripts | |
echo "" | |
- name: Build ${{ matrix.settings.dirCohortInitiator }} | |
env: | |
SDK_CLIENT_PACKAGE_VERSION: ${{ steps.sdk-client-version.outputs.SDK_CLIENT_PACKAGE_VERSION }} | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SKIP_NAPI_RS_STEP: true # this will re-use already bundled native lib | |
shell: bash | |
run: |- | |
cd ${{ matrix.settings.dirCohortInitiator }} | |
pwd | |
ls -l | |
rm package-lock.json || true | |
echo "D: npm install $SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION --foreground-scripts" | |
#npm install "$SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION" --foreground-scripts | |
npm run build --foreground-scripts | |
- name: Unublish SDK NPMs on failure | |
if: ${{ failure() }} | |
shell: bash | |
env: | |
SDK_JS_PACKAGE_VERSION: ${{ steps.sdk-js-version.outputs.SDK_JS_PACKAGE_VERSION }} | |
SDK_CLIENT_PACKAGE_VERSION: ${{ steps.sdk-client-version.outputs.SDK_CLIENT_PACKAGE_VERSION }} | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: |- | |
cd ${{ matrix.settings.dirSdkJsClient }} | |
pwd | |
ls -l | |
echo "Current version is" | |
npm version | |
echo "Unpublishing faulty version" | |
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" | |
echo "all_versions_sdk_client_js=" | |
echo $all_versions_sdk_client_js | |
echo "" | |
echo "curl command used:" | |
echo "curl -L -H 'Accept: application/vnd.github+json' -H 'Authorization: Bearer ...' -H 'X-GitHub-Api-Version: $API_VERSION' $API_URL/cohort_sdk_client/versions" | |
echo "existing with error..." | |
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" | |
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: | |
SDK_CLIENT_PACKAGE_VERSION: ${{ steps.sdk-client-version.outputs.SDK_CLIENT_PACKAGE_VERSION }} | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SKIP_NAPI_RS_STEP: true # this will re-use already bundled native lib | |
shell: bash | |
run: |- | |
cd ${{ matrix.settings.dirCohortInitiator }} | |
pwd | |
ls -l | |
rm package-lock.json || true | |
echo "D: npm install $SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION --foreground-scripts" | |
npm install "$SDK_CLIENT_PACKAGE_NAME@$SDK_CLIENT_PACKAGE_VERSION" --foreground-scripts | |
npm run build --foreground-scripts | |
- name: Unublish SDK NPMs on failure | |
if: ${{ failure() }} | |
shell: bash | |
env: | |
SDK_JS_PACKAGE_VERSION: ${{ steps.sdk-js-version.outputs.SDK_JS_PACKAGE_VERSION }} | |
SDK_CLIENT_PACKAGE_VERSION: ${{ steps.sdk-client-version.outputs.SDK_CLIENT_PACKAGE_VERSION }} | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: |- | |
cd ${{ matrix.settings.dirSdkJsClient }} | |
pwd | |
ls -l | |
echo "Current version is" | |
npm version | |
echo "Unpublishing faulty version" | |
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" | |
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" |