Skip to content

Commit 28e3bf8

Browse files
committed
add workflows
1 parent 8cd83dd commit 28e3bf8

File tree

3 files changed

+113
-1
lines changed

3 files changed

+113
-1
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This file is a generic workflow used across multiple Intercom repos.
2+
# The source of truth lives at:
3+
# https://github.com/intercom/github-action-workflows
4+
# If you feel you need to make a change to this workflow, please reach out
5+
# to team-builder-tools on Slack.
6+
7+
name: Publish to GitHub Package Registry
8+
9+
on:
10+
push:
11+
branches:
12+
- main
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v2
20+
21+
- name: Fetch all tags
22+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
23+
24+
- name: Setup NodeJS Runtime
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: 18
28+
registry-url: 'https://npm.pkg.github.com'
29+
scope: '@intercom'
30+
31+
- name: Publish new tag
32+
run: |
33+
package_version="v$(node -e "console.log(require('./package.json').version)")"
34+
tag_existed_before=$(git tag --list | grep "$package_version" | wc -l)
35+
if [ "$tag_existed_before" == "0" ]; then
36+
git config --global user.email "[email protected]"
37+
git config --global user.name "intercom/github-action-workflows - Auto-Tag - GitHub Action"
38+
git tag -a "$package_version" -m "$package_version"
39+
git push origin "$package_version"
40+
echo "Pushed tag $package_version"
41+
else
42+
echo "Tag $package_version already exists, not overwriting"
43+
fi
44+
45+
- name: Publish to GPR
46+
# We need to remove the .npmrc here because it contains a read-only
47+
# GPR token which takes precendence over the read-write token
48+
# provided by GitHub via action secrets below
49+
run: rm .npmrc || true; npm publish || true
50+
env:
51+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# This file is a generic workflow used across multiple Intercom repos.
2+
# The source of truth lives at:
3+
# https://github.com/intercom/github-action-workflows
4+
# If you feel you need to make a change to this workflow, please reach out
5+
# to team-builder-tools on Slack.
6+
7+
name: Publish pre-release version to GitHub Package Registry
8+
9+
on:
10+
push:
11+
branches-ignore:
12+
- main
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v2
20+
21+
- name: Fetch all tags
22+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
23+
24+
- name: Setup NodeJS Runtime
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: 18
28+
registry-url: 'https://npm.pkg.github.com'
29+
scope: '@intercom'
30+
31+
- name: Check version changes
32+
run: echo "##[set-output name=is-pre-release;]$(node -e 'console.log(require(`./package.json`).version.includes(`-`))')"
33+
id: package-version-check
34+
35+
- name: Publish new tag
36+
if: steps.package-version-check.outputs.is-pre-release == 'true'
37+
run: |
38+
package_version="v$(node -e "console.log(require('./package.json').version)")"
39+
tag_existed_before=$(git tag --list | grep "$package_version" | wc -l)
40+
if [ "$tag_existed_before" == "0" ]; then
41+
git config --global user.email "[email protected]"
42+
git config --global user.name "intercom/github-action-workflows - Auto-Tag - GitHub Action"
43+
git tag -a "$package_version" -m "$package_version"
44+
git push origin "$package_version"
45+
echo "Pushed tag $package_version"
46+
else
47+
echo "Tag $package_version already exists, not overwriting"
48+
fi
49+
50+
- name: Install dependencies
51+
if: steps.package-version-check.outputs.is-pre-release == 'true'
52+
run: yarn install --frozen-lockfile
53+
54+
- name: Publish to GPR
55+
if: steps.package-version-check.outputs.is-pre-release == 'true'
56+
# We need to remove the .npmrc here because it contains a read-only
57+
# GPR token which takes precendence over the read-write token
58+
# provided by GitHub via action secrets below
59+
run: rm .npmrc || true; npm publish || true
60+
env:
61+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "intercom-openapi",
2+
"name": "@intercom/intercom-openapi",
33
"version": "1.0.0",
44
"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",
55
"scripts": {

0 commit comments

Comments
 (0)