Release #189
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
permissions: | |
contents: read | |
jobs: | |
log-updates: | |
name: Log packages to publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the new tag | |
uses: actions/checkout@v3 | |
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; | |
git-version: | |
permissions: | |
contents: write # for Git to git push | |
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@v3 | |
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: | | |
make new-version-checklist | |
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 "branch=$branch" >> $GITHUB_OUTPUT | |
git push "https://babel-bot:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" HEAD:"$branch" --follow-tags | |
check-release-type: | |
name: Check the release type | |
runs-on: ubuntu-latest | |
needs: git-version | |
# The default condition is success(), but this is false when one of the previous jobs is skipped | |
if: | | |
always() && | |
(needs.git-version.result == 'success' || needs.git-version.result == 'skipped') | |
outputs: | |
is-babel-8: ${{ steps.is-babel-8.outputs.result }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Checkout the temporary branch | |
if: needs.git-version.result == 'success' | |
run: git checkout ${{ needs.git-version.outputs.branch }} | |
- name: Check if Babel 8 | |
id: is-babel-8 | |
run: | | |
git log -1 --format=%B HEAD \ | |
| node -p "'result=' + fs.readFileSync(0, 'utf8').includes('v8')" \ | |
>> $GITHUB_OUTPUT | |
- name: Log | |
run: echo ${{ steps.is-babel-8.outputs.result }} | |
npm-release: | |
name: Build, Test and Publish | |
runs-on: ubuntu-latest | |
needs: | |
- check-release-type | |
- git-version | |
environment: npm | |
# The default condition is success(), but this is false when one of the previous jobs is skipped | |
if: | | |
always() && | |
(needs.git-version.result == 'success' || needs.git-version.result == 'skipped') && | |
needs.check-release-type.result == 'success' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Checkout the temporary branch | |
if: needs.git-version.result == 'success' | |
run: git checkout ${{ needs.git-version.outputs.branch }} | |
- name: Build and Test | |
run: make prepublish | |
env: | |
# Hack: use FORCE_COLOR so that supports-color@5 returnes true for GitHub CI | |
# Remove once `chalk` is bumped to 4.0. | |
FORCE_COLOR: true | |
# Note: `false` doesn't work here, because env vars are strings and Boolean('false') | |
# is true. Use the empry string instead. | |
BABEL_8_BREAKING: ${{ needs.check-release-type.outputs.is-babel-8 == 'true' || '' }} | |
- name: Publish to npm (Babel 7) | |
run: yarn release-tool publish --yes | |
if: needs.check-release-type.outputs.is-babel-8 == 'false' | |
env: | |
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Publish to npm (Babel 8) | |
run: yarn release-tool publish --yes --tag next | |
if: needs.check-release-type.outputs.is-babel-8 == 'true' | |
env: | |
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
BABEL_8_BREAKING: true | |
USE_ESM: true | |
github-release: | |
name: Create GitHub release draft | |
runs-on: ubuntu-latest | |
needs: | |
- check-release-type | |
- git-version | |
# The default condition is success(), but this is false when one of the previous jobs is skipped | |
if: | | |
always() && | |
(needs.git-version.result == 'success' || needs.git-version.result == 'skipped') && | |
needs.check-release-type.result == 'success' && | |
needs.check-release-type.outputs.is-babel-8 == 'false' | |
outputs: | |
is-main: ${{ steps.is-main.outputs.result == 1 }} | |
changelog: ${{ steps.changelog.outputs.changelog }} | |
version: ${{ steps.tags.outputs.new }} | |
steps: | |
- uses: actions/checkout@v3 | |
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: | |
permissions: | |
contents: write # for Git to git 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@v3 | |
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 }} |