-
Notifications
You must be signed in to change notification settings - Fork 25
129 lines (110 loc) · 4.58 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Release
on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
steps:
# Get GitHub token via the CT Changesets App
- name: Generate GitHub token (via CT Changesets App)
id: generate_github_token
uses: tibdex/[email protected]
with:
app_id: ${{ secrets.CT_CHANGESETS_APP_ID }}
private_key: ${{ secrets.CT_CHANGESETS_APP_PEM }}
- name: Get App user
id: get_app_user
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
run: |
export GH_APP_USER=`gh api /users/ct-changesets%5Bbot%5D | jq .id`
echo "email=${GH_APP_USER}+ct-changesets[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
with:
# Pass a personal access token (using our CT Changesets App) to be able to trigger other workflows
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
# https://github.community/t/action-does-not-trigger-another-on-push-tag-action/17148/8
token: ${{ steps.generate_github_token.outputs.token }}
- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm
- name: Setup Node (uses version in .nvmrc)
uses: actions/setup-node@v4
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Building packages
run: yarn build
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@master
with:
publish: yarn changeset publish
version: yarn changeset:version-and-format
commit: 'ci(changesets): version packages'
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
- name: Dispatch repository event
if: steps.changesets.outputs.published == 'true'
run: |
gh api --method POST /repos/commercetools/commercetools-typescript-sdk/dispatches -f "event_type=new_release"
env:
GITHUB_TOKEN: ${{ steps.generate_github_token.outputs.token }}
- name: Convert markdown to slack markdown
uses: LoveToKnow/[email protected]
id: markdown
with:
text: |
A new version of [ts-sdk](https://github.com/commercetools/commercetools-sdk-typescript) was published to npm :rocket:
- name: Slack Notification
if: steps.changesets.outputs.published == 'true'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: devtooling-automation
SLACK_COLOR: ${{ job.status }}
MSG_MINIMAL: actions url,commit
SLACK_TITLE: Typescript SDK Release ✨
SLACK_MESSAGE: ${{steps.markdown.outputs.text}}
SLACK_USERNAME: rtBot
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: "Switch SDK to after release branch"
if: steps.changesets.outputs.published == 'true'
run: |
git fetch --depth=1 origin after-release || true
git checkout -B after-release origin/after-release || true
git checkout -B after-release
git log -1
- name: "remove API reference commit SHA"
if: steps.changesets.outputs.published == 'true'
run: rm -rf reference.txt
continue-on-error: true
- uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842 # v5.0.1
if: steps.changesets.outputs.published == 'true'
with:
branch: after-release
file_pattern: 'reference.txt'
commit_message: "chore: updating API ref SHA"
commit_author: ct-changesets[bot] <${{ steps.get_app_user.outputs.email }}>
commit_user_name: ct-changesets[bot]
commit_user_email: ${{ steps.get_app_user.outputs.email }}