forked from babel/babel
195 lines (173 loc) · 6.28 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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
# This input isn't actually used as an input, but it's a reminder that
# this workflow can only automatically push patch versions.
# This is because often minor versions require human intervention, so
# it's safer if we force ourselves to always create them locally.
description: ⚠️ This workflow can only automatically release patch versions
required: true
default: patch
jobs:
log-updates:
name: Log packages to publish
runs-on: ubuntu-latest
steps:
- name: Checkout the new tag
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: This release will publish the following packages
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
yarn release-tool version --dry patch
else
git diff --name-only HEAD^..HEAD
fi;
build:
name: Build and Test
runs-on: ubuntu-latest
needs: log-updates
steps:
- uses: actions/checkout@v2
- name: Build and Test
run: make prepublish
- uses: actions/upload-artifact@v2
with:
name: build-artifact
path: |
codemods/*/lib/**/*
eslint/*/lib/**/*
packages/*/lib/**/*
codemods/*/LICENSE
eslint/*/LICENSE
packages/*/LICENSE
packages/babel-standalone/*.js
!**/node_modules/**
git-version:
name: Create git tag and commit
runs-on: ubuntu-latest
needs: log-updates
if: github.event_name == 'workflow_dispatch'
outputs:
branch: ${{ steps.push.outputs.branch }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set @babel-bot as committer
run: |
git config user.name "Babel Bot"
git config user.email "babel-bot@users.noreply.github.com"
- name: Create new version
run: yarn release-tool version -f @babel/standalone --yes patch
- name: Push to GitHub
id: push
run: |
branch="release/temp/$(git describe --abbrev=0)"
echo $branch
echo "::set-output name=branch::$branch"
git push "https://babel-bot:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" HEAD:"$branch" --follow-tags
npm-release:
name: Publish release on npm
runs-on: ubuntu-latest
needs: [git-version, build]
environment: npm
# The default condition is success(), but this is false when one of the previous jobs is skipped
if: |
always() &&
needs.build.result == 'success' &&
(needs.git-version.result == 'success' || needs.git-version.result == 'skipped')
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Checkout the temporary branch
if: needs.git-version.result == 'success'
run: git checkout ${{ needs.git-version.outputs.branch }}
- uses: actions/download-artifact@v2
with:
name: build-artifact
- name: Publish to npm
run: yarn release-tool publish --yes
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
github-release:
name: Create GitHub release draft
runs-on: ubuntu-latest
needs: [git-version, build]
# The default condition is success(), but this is false when one of the previous jobs is skipped
if: |
always() &&
needs.build.result == 'success' &&
(needs.git-version.result == 'success' || needs.git-version.result == 'skipped')
outputs:
is-main: ${{ steps.is-main.outputs.result == 1 }}
changelog: ${{ steps.changelog.outputs.changelog }}
version: ${{ steps.tags.outputs.new }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check if releasing from main
id: is-main
uses: babel/actions/ref-matches-branch@v2
with:
name: main
- name: Checkout the temporary branch
if: needs.git-version.result == 'success'
run: git checkout ${{ needs.git-version.outputs.branch }}
- name: Get tag info
id: tags
uses: babel/actions/get-release-tags@v2
- name: Generate the changelog
id: changelog
uses: babel/actions/generate-lerna-changelog@v2
with:
from: ${{ steps.tags.outputs.old }}
to: ${{ steps.tags.outputs.new }}
env:
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
- name: Create a draft GitHub release
uses: babel/actions/publish-github-release@v2
with:
tag: ${{ steps.tags.outputs.new }}
changelog: ${{ steps.changelog.outputs.changelog }}
token: ${{ secrets.BOT_TOKEN }}
github-push:
name: Push release commit to "main"
runs-on: ubuntu-latest
needs: [npm-release, github-release, git-version]
# The default condition is success(), but this is false when one of the previous jobs is skipped
if: |
always() &&
needs.npm-release.result == 'success' &&
needs.github-release.result == 'success' &&
needs.github-release.outputs.is-main
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Checkout the temporary branch
if: needs.git-version.result == 'success'
run: git checkout ${{ needs.git-version.outputs.branch }}
- name: Update CHANGELOG.md
uses: babel/actions/update-changelog@v2
with:
changelog: ${{ needs.github-release.outputs.changelog }}
- name: Commit CHANGELOG.md
run: |
git add CHANGELOG.md
git -c user.name="Babel Bot" -c user.email="babel-bot@users.noreply.github.com" \
commit -m "Add ${{ needs.github-release.outputs.version }} to CHANGELOG.md [skip ci]" --no-verify --quiet
- name: Push to GitHub
run: |
git push "https://babel-bot:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" HEAD:main --follow-tags
- name: Delete temporary branch from GitHub
if: needs.git-version.result == 'success'
run:
git push "https://babel-bot:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" :${{ needs.git-version.outputs.branch }}