-
Notifications
You must be signed in to change notification settings - Fork 9
139 lines (124 loc) · 3.65 KB
/
update-and-publish.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
130
131
132
133
134
135
136
137
138
139
name: Update prisma client and publish the package
on:
workflow_call:
inputs:
npmTag:
description: npm tag to publish to
type: string
required: true
version:
description: npm version to publish
type: string
required: true
secrets:
SLACK_WEBHOOK_URL:
required: true
NPM_TOKEN:
required: true
workflow_dispatch:
inputs:
npmTag:
description: npm tag to publish to
type: string
required: true
version:
description: npm version to publish
type: string
required: true
concurrency:
group: publish
jobs:
update:
name: Update client & engines on a temporary branch
runs-on: ubuntu-latest
env:
TMP_BRANCH_NAME: tmp/release-${{ inputs.npmTag }}-${{ inputs.version }}
NPM_TAG: ${{ inputs.npmTag }}
NPM_VERSION: ${{ inputs.version }}
outputs:
tmpBranch: ${{ steps.do-update.outputs.tmpBranch }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.PRISMA_BOT_TOKEN }}
- name: Setup
uses: ./.github/actions/setup
- name: Update version in temporary branch
id: do-update
run: |
git checkout -b "$TMP_BRANCH_NAME"
yarn bump-client "$NPM_TAG" "$NPM_VERSION"
git config user.email prismabots@gmail.com
git config user.name Prismo
git commit -am "chore(deps): Update prisma to $NPM_VERSION on $NPM_TAG"
git push origin "$TMP_BRANCH_NAME"
echo "tmpBranch=$TMP_BRANCH_NAME" >> "$GITHUB_OUTPUT"
test:
name: Test release branch
needs:
- update
uses: ./.github/workflows/test.yml
with:
ref: ${{ needs.update.outputs.tmpBranch }}
secrets: inherit
publish:
name: Merge temp branch back and publish
runs-on: ubuntu-latest
needs:
- update
- test
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.PRISMA_BOT_TOKEN }}
- name: Merge temp release branch back into main
env:
TMP_BRANCH_NAME: ${{ needs.update.outputs.tmpBranch }}
run: |
git fetch origin "$TMP_BRANCH_NAME"
git merge --ff-only "origin/$TMP_BRANCH_NAME"
- name: Setup
uses: ./.github/actions/setup
- name: Publish
env:
NPM_TAG: ${{ inputs.npmTag }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn npm publish --tag "$NPM_TAG"
- name: Push
run: git push origin main
notify-on-failure:
name: Notify on publish failure
needs:
- update
- test
- publish
if: ${{ always() && contains(needs.*.result, 'failure') }}
runs-on: ubuntu-latest
steps:
- name: Set current job url in SLACK_FOOTER env var
run: echo "SLACK_FOOTER=<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID|Click here to go to the job logs>" >> $GITHUB_ENV
- name: Slack Notification on Failure
uses: rtCamp/action-slack-notify@v2.3.0
env:
SLACK_TITLE: 'React Native publish failed'
SLACK_COLOR: '#FF0000'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_CHANNEL: feed-react-native-publish-failures
finalize:
name: Cleanup
runs-on: ubuntu-latest
needs:
- update
- test
- publish
if: always()
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Remove temporary branch
env:
TMP_BRANCH_NAME: ${{ needs.update.outputs.tmpBranch }}
run: |
git push --delete origin "$TMP_BRANCH_NAME"