-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
160 lines (137 loc) · 5.89 KB
/
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: Publish
run-name: Publish new version on ${{ github.ref_name }}, triggered by ${{ github.triggering_actor }}
on:
push:
branches:
- latest-release
- next-release
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
permissions:
contents: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
jobs:
publish:
name: Publish new version
runs-on: ubuntu-latest
environment: release
defaults:
run:
working-directory: scripts
steps:
- name: Checkout ${{ github.ref_name }}
uses: actions/checkout@v3
with:
fetch-depth: 100
token: ${{ secrets.GH_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.yarn/berry/cache
key: yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
restore-keys: |
yarn-v1-${{ hashFiles('scripts/yarn.lock') }}-${{ hashFiles('code/yarn.lock') }}
yarn-v1-${{ hashFiles('scripts/yarn.lock') }}
yarn-v1
- name: Install script dependencies
run: |
yarn install
- name: Get current version
id: version
run: yarn release:get-current-version
- name: Check if publish is needed
id: publish-needed
run: yarn release:is-version-published ${{ steps.version.outputs.current-version }}
- name: Check release vs prerelease
if: steps.publish-needed.outputs.published == 'false'
id: is-prerelease
run: yarn release:is-prerelease
- name: Install code dependencies
if: steps.publish-needed.outputs.published == 'false'
working-directory: .
run: yarn task --task=install --start-from=install
- name: Publish
if: steps.publish-needed.outputs.published == 'false'
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: yarn release:publish --tag ${{ steps.is-prerelease.outputs.prerelease == 'true' && 'next' || 'latest' }} --verbose
- name: Get target branch
id: target
run: echo "target=${{ github.ref_name == 'next-release' && 'next' || 'main' }}" >> $GITHUB_OUTPUT
- name: Get changelog for ${{ steps.version.outputs.current-version }}
if: steps.publish-needed.outputs.published == 'false'
id: changelog
run: yarn release:get-changelog-from-file ${{ steps.version.outputs.current-version }}
# tags are needed to get list of patches to label as picked
- name: Fetch git tags
if: github.ref_name == 'latest-release'
run: git fetch --tags origin
- name: Label patch PRs as picked
if: github.ref_name == 'latest-release'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn release:label-patches
- name: Create GitHub Release
if: steps.publish-needed.outputs.published == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create \
v${{ steps.version.outputs.current-version }} \
--repo "${{ github.repository }}" \
--target ${{ github.ref_name }} \
--title "v${{ steps.version.outputs.current-version }}" \
--notes "${{ steps.changelog.outputs.changelog }}" \
${{ steps.is-prerelease.outputs.prerelease == 'true' && '--prerelease' || '' }}
- name: Merge ${{ github.ref_name }} into ${{ steps.target.outputs.target }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin ${{ steps.target.outputs.target }}
git checkout ${{ steps.target.outputs.target }}
git merge ${{ github.ref_name }}
git push origin ${{ steps.target.outputs.target }}
- name: Sync CHANGELOG.md from `main` to `next`
if: github.ref_name == 'latest-release'
working-directory: .
run: |
git fetch origin next
git checkout next
git pull
git checkout origin/main ./CHANGELOG.md
git add ./CHANGELOG.md
git commit -m "Update CHANGELOG.md for v${{ steps.version.outputs.current-version }}"
git push origin next
- name: Sync versions/next.json from `next` to `main`
if: github.ref_name == 'next-release'
working-directory: .
run: |
git fetch origin main
git checkout main
git pull
git checkout origin/next ./docs/versions/next.json
git add ./docs/versions/next.json
git commit -m "Update versions/next.json for v${{ steps.version.outputs.current-version }}"
git push origin main
# Force push from next to main if it is not a prerelease, and this release is from next-release
# This happens when eg. next has been tracking 7.1.0-alpha.X, and now we want to release 7.1.0
# This will keep release-next, next and main all tracking v7.1.0
# - name: Force push ${{ steps.target.outputs.target }} to main
# if: steps.publish-needed.outputs.published == 'false' && steps.target.outputs.target == 'next' && !steps.is-prerelease.outputs.prerelease
# run: |
# git push --force origin ${{ steps.target.outputs.target }}:main
- name: Report job failure to Discord
if: failure()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_MONITORING_URL }}
uses: Ilshidur/action-discord@master
with:
args: 'The GitHub Action for publishing version ${{ steps.version.outputs.current-version }} (triggered by ${{ github.triggering_actor }}) failed! See run at: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'