diff --git a/.github/workflows/publish_main_gpr.yml b/.github/workflows/publish_main_gpr.yml new file mode 100644 index 0000000..6fc2560 --- /dev/null +++ b/.github/workflows/publish_main_gpr.yml @@ -0,0 +1,42 @@ +name: Publish to GitHub Package Registry + +on: + push: + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + 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@v4 + 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 + 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..50db9d8 --- /dev/null +++ b/.github/workflows/publish_pre_release_gpr.yml @@ -0,0 +1,52 @@ +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@v4 + + - name: Fetch all tags + run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + + - name: Setup NodeJS Runtime + uses: actions/setup-node@v4 + 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' + run: rm .npmrc || true; npm publish || true + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 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 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": {