From 28e3bf8109688cbd7f8bc9c51006a428608c4ad5 Mon Sep 17 00:00:00 2001 From: Liz Moy Date: Tue, 25 Feb 2025 11:46:02 +0000 Subject: [PATCH 1/4] add workflows --- .github/workflows/publish_main_gpr.yml | 51 ++++++++++++++++ .github/workflows/publish_pre_release_gpr.yml | 61 +++++++++++++++++++ package.json | 2 +- 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish_main_gpr.yml create mode 100644 .github/workflows/publish_pre_release_gpr.yml diff --git a/.github/workflows/publish_main_gpr.yml b/.github/workflows/publish_main_gpr.yml new file mode 100644 index 0000000..9b94545 --- /dev/null +++ b/.github/workflows/publish_main_gpr.yml @@ -0,0 +1,51 @@ +# This file is a generic workflow used across multiple Intercom repos. +# The source of truth lives at: +# https://github.com/intercom/github-action-workflows +# If you feel you need to make a change to this workflow, please reach out +# to team-builder-tools on Slack. + +name: Publish to GitHub Package Registry + +on: + push: + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Fetch all tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + + - name: Setup NodeJS Runtime + uses: actions/setup-node@v2 + with: + node-version: 18 + registry-url: 'https://npm.pkg.github.com' + scope: '@intercom' + + - name: Publish new tag + run: | + package_version="v$(node -e "console.log(require('./package.json').version)")" + tag_existed_before=$(git tag --list | grep "$package_version" | wc -l) + if [ "$tag_existed_before" == "0" ]; then + git config --global user.email "intercom-gpr-reader@intercom.com" + git config --global user.name "intercom/github-action-workflows - Auto-Tag - GitHub Action" + git tag -a "$package_version" -m "$package_version" + git push origin "$package_version" + echo "Pushed tag $package_version" + else + echo "Tag $package_version already exists, not overwriting" + fi + + - name: Publish to GPR + # We need to remove the .npmrc here because it contains a read-only + # GPR token which takes precendence over the read-write token + # provided by GitHub via action secrets below + run: rm .npmrc || true; npm publish || true + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish_pre_release_gpr.yml b/.github/workflows/publish_pre_release_gpr.yml new file mode 100644 index 0000000..414d71c --- /dev/null +++ b/.github/workflows/publish_pre_release_gpr.yml @@ -0,0 +1,61 @@ +# This file is a generic workflow used across multiple Intercom repos. +# The source of truth lives at: +# https://github.com/intercom/github-action-workflows +# If you feel you need to make a change to this workflow, please reach out +# to team-builder-tools on Slack. + +name: Publish pre-release version to GitHub Package Registry + +on: + push: + branches-ignore: + - main + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Fetch all tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + + - name: Setup NodeJS Runtime + uses: actions/setup-node@v2 + with: + node-version: 18 + registry-url: 'https://npm.pkg.github.com' + scope: '@intercom' + + - name: Check version changes + run: echo "##[set-output name=is-pre-release;]$(node -e 'console.log(require(`./package.json`).version.includes(`-`))')" + id: package-version-check + + - name: Publish new tag + if: steps.package-version-check.outputs.is-pre-release == 'true' + run: | + package_version="v$(node -e "console.log(require('./package.json').version)")" + tag_existed_before=$(git tag --list | grep "$package_version" | wc -l) + if [ "$tag_existed_before" == "0" ]; then + git config --global user.email "intercom-gpr-reader@intercom.com" + git config --global user.name "intercom/github-action-workflows - Auto-Tag - GitHub Action" + git tag -a "$package_version" -m "$package_version" + git push origin "$package_version" + echo "Pushed tag $package_version" + else + echo "Tag $package_version already exists, not overwriting" + fi + + - name: Install dependencies + if: steps.package-version-check.outputs.is-pre-release == 'true' + run: yarn install --frozen-lockfile + + - name: Publish to GPR + if: steps.package-version-check.outputs.is-pre-release == 'true' + # We need to remove the .npmrc here because it contains a read-only + # GPR token which takes precendence over the read-write token + # provided by GitHub via action secrets below + run: rm .npmrc || true; npm publish || true + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index ebe7267..a522da4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "intercom-openapi", + "name": "@intercom/intercom-openapi", "version": "1.0.0", "description": "This is the version controlled openapi spec for our public facing API's at developers.intercom.com, our external documenation site for people integrating into Intercom", "scripts": { From 1719480690dc6b88f22c8539c8a47d103aab841d Mon Sep 17 00:00:00 2001 From: Liz Moy Date: Tue, 25 Feb 2025 11:53:57 +0000 Subject: [PATCH 2/4] add nvmrc --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..a58d2d2 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18.18.2 \ No newline at end of file From 64efda0432c59638d7cae5de161703a6ea6b4a7b Mon Sep 17 00:00:00 2001 From: Liz Moy Date: Tue, 25 Feb 2025 13:16:47 +0000 Subject: [PATCH 3/4] update to v4 --- .github/workflows/publish_main_gpr.yml | 4 ++-- .github/workflows/publish_pre_release_gpr.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish_main_gpr.yml b/.github/workflows/publish_main_gpr.yml index 9b94545..418f5cd 100644 --- a/.github/workflows/publish_main_gpr.yml +++ b/.github/workflows/publish_main_gpr.yml @@ -16,13 +16,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Fetch all tags run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - name: Setup NodeJS Runtime - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: 18 registry-url: 'https://npm.pkg.github.com' diff --git a/.github/workflows/publish_pre_release_gpr.yml b/.github/workflows/publish_pre_release_gpr.yml index 414d71c..e59979b 100644 --- a/.github/workflows/publish_pre_release_gpr.yml +++ b/.github/workflows/publish_pre_release_gpr.yml @@ -16,13 +16,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Fetch all tags run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - name: Setup NodeJS Runtime - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: 18 registry-url: 'https://npm.pkg.github.com' From 97ddfbd36d7c69fbe2176fe168ae70f14a113744 Mon Sep 17 00:00:00 2001 From: Liz Moy Date: Thu, 27 Feb 2025 14:55:41 +0000 Subject: [PATCH 4/4] remove comments --- .github/workflows/publish_main_gpr.yml | 9 --------- .github/workflows/publish_pre_release_gpr.yml | 9 --------- 2 files changed, 18 deletions(-) diff --git a/.github/workflows/publish_main_gpr.yml b/.github/workflows/publish_main_gpr.yml index 418f5cd..6fc2560 100644 --- a/.github/workflows/publish_main_gpr.yml +++ b/.github/workflows/publish_main_gpr.yml @@ -1,9 +1,3 @@ -# This file is a generic workflow used across multiple Intercom repos. -# The source of truth lives at: -# https://github.com/intercom/github-action-workflows -# If you feel you need to make a change to this workflow, please reach out -# to team-builder-tools on Slack. - name: Publish to GitHub Package Registry on: @@ -43,9 +37,6 @@ jobs: fi - name: Publish to GPR - # We need to remove the .npmrc here because it contains a read-only - # GPR token which takes precendence over the read-write token - # provided by GitHub via action secrets below run: rm .npmrc || true; npm publish || true env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish_pre_release_gpr.yml b/.github/workflows/publish_pre_release_gpr.yml index e59979b..50db9d8 100644 --- a/.github/workflows/publish_pre_release_gpr.yml +++ b/.github/workflows/publish_pre_release_gpr.yml @@ -1,9 +1,3 @@ -# This file is a generic workflow used across multiple Intercom repos. -# The source of truth lives at: -# https://github.com/intercom/github-action-workflows -# If you feel you need to make a change to this workflow, please reach out -# to team-builder-tools on Slack. - name: Publish pre-release version to GitHub Package Registry on: @@ -53,9 +47,6 @@ jobs: - name: Publish to GPR if: steps.package-version-check.outputs.is-pre-release == 'true' - # We need to remove the .npmrc here because it contains a read-only - # GPR token which takes precendence over the read-write token - # provided by GitHub via action secrets below run: rm .npmrc || true; npm publish || true env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}