Skip to content

chore(release): v5.0.0 #24

chore(release): v5.0.0

chore(release): v5.0.0 #24

Workflow file for this run

# inspired by
# - https://github.com/babel/babel/blob/a32cf83f6b41f49202f2aec4189243da9ea0d895/.github/workflows/release.yml
# - https://github.com/babel/actions/tree/03731d9c1d1b0d3e4609a78151679cf3de51f665
name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
inputs:
version:
description:
⚠️ This workflow can only automatically release versions. Check out
https://github.com/lerna/lerna/tree/main/commands/version#semver-bump
for more details.
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@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0
- name: This release will publish the following packages
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo ${{ github.event.inputs.version }}
else
git diff --name-only HEAD^..HEAD
fi;
git-version:
permissions:
contents: write # for Git to git push
name: Create git tag and commit when workflow was manually dispatched
runs-on: ubuntu-latest
needs: log-updates
if: github.event_name == 'workflow_dispatch'
outputs:
branch: ${{ steps.push.outputs.branch }}
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0
- name: Set @natterstefan-bot as committer
run: |
git config user.name "natterstefan Bot"
git config user.email "natterstefan-bot@users.noreply.github.com"
- uses: actions/setup-node@16352bb09bc672a073e326c2cc1d3d7d2a3e577e
with:
node-version: 18
cache: "yarn"
- run: yarn --prefer-offline --frozen-lockfile --no-progress --silent
# prettier-ignore
- run: HUSKY_SKIP_HOOKS=1 yarn lerna version ${{ github.event.inputs.version }} --no-commit-hooks --no-changelog --yes --force-publish
- 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://natterstefan-bot:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" HEAD:"$branch" --follow-tags
npm-release:
name: Lint and Test
runs-on: ubuntu-latest
needs: 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')
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
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/setup-node@16352bb09bc672a073e326c2cc1d3d7d2a3e577e
with:
node-version: 18
cache: "yarn"
- run: yarn --prefer-offline --frozen-lockfile --no-progress --silent
- run: yarn lint
- run: yarn test
# TODO: enable auto publish to npm again
# - run: yarn lerna:publish --yes
# env:
# YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
github-release:
name: Create GitHub release draft
runs-on: ubuntu-latest
needs: [npm-release, 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-main: ${{ steps.is-main.outputs.result == 1 }}
changelog: ${{ steps.changelog.outputs.changelog }}
version: ${{ steps.tags.outputs.new }}
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0
- name: Check if releasing from main
id: is-main
uses: babel/actions/ref-matches-branch@03731d9c1d1b0d3e4609a78151679cf3de51f665
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@03731d9c1d1b0d3e4609a78151679cf3de51f665
- name: Generate the changelog
id: changelog
# alternative: https://github.com/riskledger/generate-changelog/blob/9708d3db7d3bb62ce90bff6352b32e3edbac59c7/main.js
uses: babel/actions/generate-lerna-changelog@03731d9c1d1b0d3e4609a78151679cf3de51f665
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@03731d9c1d1b0d3e4609a78151679cf3de51f665
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@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: 0
- name: Checkout the temporary branch
if: needs.git-version.result == 'success'
run: git checkout ${{ needs.git-version.outputs.branch }}
- name: Set @natterstefan-bot as committer
run: |
git config user.name "natterstefan Bot"
git config user.email "natterstefan-bot@users.noreply.github.com"
- name: Update CHANGELOG.md
uses: babel/actions/update-changelog@03731d9c1d1b0d3e4609a78151679cf3de51f665
with:
changelog: ${{ needs.github-release.outputs.changelog }}
- name: Commit CHANGELOG.md
run: |
git add CHANGELOG.md
git -c user.name="natterstefan Bot" -c user.email="natterstefan-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://natterstefan-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'
# prettier-ignore
run: git push "https://natterstefan-bot:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" :${{ needs.git-version.outputs.branch }}