babel/.github/workflows/release.yml
Nicolò Ribaudo 5b5b548036
Publish to npm from GitHub actions (#12526)
* Publish to npm from GitHub actions

* Remove publish-ci from Makefile

This was meant to be used _now_, but I didn't end up using it

* Test

* Revert "Test"

This reverts commit 04095c17db8352710c12849a5b1fa53e853bd6f5.
2020-12-23 00:18:03 +01:00

85 lines
2.4 KiB
YAML

name: Release
on:
push:
tags: ["v*"]
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: 2
- name: This release will publish the following packages
run: git diff --name-only HEAD^..HEAD
npm-release:
name: Publish release on npm
runs-on: ubuntu-latest
needs: log-updates
environment: npm
steps:
- name: Checkout the new tag
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build and Test
run: make prepublish
- name: Publish to npm
run: yarn release-tool publish --yes
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
github-release:
name: Trigger GitHub release
runs-on: ubuntu-latest
needs: npm-release
steps:
- name: Checkout the new tag
uses: actions/checkout@v2
with:
fetch-depth: 0
- 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 }}
- name: Check if releasing from main
id: is_main
uses: babel/actions/ref-matches-branch@v2
with:
name: main
- name: Update CHANGELOG.md
if: steps.is_main.outputs.result == 1
uses: babel/actions/update-changelog@v2
with:
changelog: ${{ steps.changelog.outputs.changelog }}
- name: Commit CHANGELOG.md
if: steps.is_main.outputs.result == 1
run: |
git add CHANGELOG.md
git -c user.name="Babel Bot" -c user.email="babel-bot@users.noreply.github.com" \
commit -m "Add ${{ steps.tags.outputs.new }} to CHANGELOG.md [skip ci]" --no-verify --quiet
git push "https://babel-bot:${{ secrets.BOT_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" main