From eb734b8d984869a6a3e66e312275bdd373d9098c Mon Sep 17 00:00:00 2001 From: Benaya Christo Date: Wed, 29 Jun 2022 10:34:12 +0800 Subject: [PATCH 1/2] add double publish pipeline --- .buddy/double-publish-github-registry.yaml | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .buddy/double-publish-github-registry.yaml diff --git a/.buddy/double-publish-github-registry.yaml b/.buddy/double-publish-github-registry.yaml new file mode 100644 index 0000000..4b52015 --- /dev/null +++ b/.buddy/double-publish-github-registry.yaml @@ -0,0 +1,41 @@ +- pipeline: "Double publish module to NPM & github" + trigger_mode: "ON_EVERY_PUSH" + ref_name: "refs/tags/*" + ref_type: "WILDCARD" + priority: "NORMAL" + fetch_all_refs: true + trigger_condition: "ALWAYS" + actions: + - action: 'Execute: npm publish for github (new) registry' + type: 'BUILD' + working_directory: "/buddy/xendit-js-node" + docker_image_name: 'library/node' + docker_image_tag: '10' + execute_commands: + # move to client path + - "cd $CLIENT_PATH" + # Add tokens for github and NPM + - 'echo -ne "# npm registry config\n//registry.npmjs.org/:_authToken=$NPM_PUBLISH_TOKEN\n@boxbag:registry=https://registry.npmjs.org/\n\r# github registry config\n//npm.pkg.github.com/:_authToken=$GITHUB_REGISTRY_TOKEN\n@xendit:registry=https://npm.pkg.github.com/" >> .npmrc' + # update package's scope to publish to NPM boxbag's registry + - "if [[ $BUDDY_EXECUTION_TAG != v$(node -p -e \"require('./package.json').version\") ]];" + - "then" + - " echo \"Github release tag does not match package.json version tag\"" + - " exit 1" + - "fi" + - sed -ie '/name/s/xendit/boxbag/' package.json + - npm install + - npm publish + + # publish + # update package's scope to publish to xendit's github registry + - 'sedRepoString=", \"repository\": { \"type\": \"git\", \"url\": \"git+https:\/\/github.com\/xendit\/xendit-js-node.git\" }"' + - 'sed -i -e "$(( $( wc -l < package.json) -1 ))s/$/\n$sedRepoString/" package.json' + - sed -ie '/name/s/boxbag/xendit/' package.json + - "npm ci" + - "npm publish" + - rm .npmrc + volume_mappings: + - "/:/buddy/xendit-js-node" + trigger_condition: 'ALWAYS' + ignore_errors: true + shell: 'BASH' From 6b60eec70f43a1090112cf2fddcda8f3de096e58 Mon Sep 17 00:00:00 2001 From: Benaya Christo <106946042+benaya-christo@users.noreply.github.com> Date: Wed, 6 Jul 2022 17:03:02 +0800 Subject: [PATCH 2/2] Update double-publish-github-registry.yaml fix: sed command to rename package name registries (missing @ character) more details here: https://xendit.slack.com/archives/C03M50ARP6Z/p1657091916659209 --- .buddy/double-publish-github-registry.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.buddy/double-publish-github-registry.yaml b/.buddy/double-publish-github-registry.yaml index 4b52015..258b590 100644 --- a/.buddy/double-publish-github-registry.yaml +++ b/.buddy/double-publish-github-registry.yaml @@ -22,15 +22,17 @@ - " echo \"Github release tag does not match package.json version tag\"" - " exit 1" - "fi" - - sed -ie '/name/s/xendit/boxbag/' package.json + - sed -ie '/name/s/@xendit/@boxbag/' package.json - npm install + # remove/modify this line if you have a different build script + - npm run build - npm publish # publish # update package's scope to publish to xendit's github registry - 'sedRepoString=", \"repository\": { \"type\": \"git\", \"url\": \"git+https:\/\/github.com\/xendit\/xendit-js-node.git\" }"' - 'sed -i -e "$(( $( wc -l < package.json) -1 ))s/$/\n$sedRepoString/" package.json' - - sed -ie '/name/s/boxbag/xendit/' package.json + - sed -ie '/name/s/@boxbag/@xendit/' package.json - "npm ci" - "npm publish" - rm .npmrc