diff --git a/.github/actions/trigger-github-release/Dockerfile b/.github/actions/trigger-github-release/Dockerfile index 69b3cb60f5..c7e17c775b 100644 --- a/.github/actions/trigger-github-release/Dockerfile +++ b/.github/actions/trigger-github-release/Dockerfile @@ -12,6 +12,7 @@ ADD entrypoint.sh /action/entrypoint.sh ADD package.json /action/package.json ADD package-lock.json /action/package-lock.json ADD release.js /action/release.js +ADD update-changelog.js /action/update-changelog.js RUN chmod +x /action/entrypoint.sh diff --git a/.github/actions/trigger-github-release/entrypoint.sh b/.github/actions/trigger-github-release/entrypoint.sh index c5fcecaffb..11c7f193e3 100755 --- a/.github/actions/trigger-github-release/entrypoint.sh +++ b/.github/actions/trigger-github-release/entrypoint.sh @@ -5,21 +5,18 @@ set -e echo "INFO: Installing action dependencies..." (cd /action; npm ci) -echo "INFO: Checking out current commit..." -git -c advice.detachedHead=false checkout $GITHUB_SHA - # GitHub doesn't support running actions on new tags yet: we need to run it on the commit. # For this reason, we can't be sure that the tag already exists. We can use the commit # message to create the tag. If the tag already exists locally, they won't conflict because # they have the same name and are on the same commit. echo "INFO: Getting release version..." -# current_tag=$(git describe --abbrev=0 --tags HEAD) -current_tag=$(git log --oneline --format=%B -1 HEAD) +# current_tag=$(git describe --abbrev=0 --tags $GITHUB_SHA) +current_tag=$(git log --oneline --format=%B -1 $GITHUB_SHA) echo "INFO: Creating new tag..." (git tag $current_tag $GITHUB_SHA) || echo "INFO: Tag already exists" -last_tag=$(git describe --abbrev=0 --tags HEAD^) +last_tag=$(git describe --abbrev=0 --tags $current_tag^) echo "INFO: New version is $current_tag; last version is $last_tag." echo "INFO: Generating the changelog..." @@ -35,4 +32,15 @@ changelog=$( echo "INFO: Publishing the new GitHub release..." echo "$changelog" | node /action/release $current_tag +echo "INFO: Updating CHANGELOG.md..." +echo "$changelog" | node /action/update-changelog + +echo "INFO: Committing changelog..." +git add CHANGELOG.md +git -c user.name="$COMMIT_AUTHOR_NAME" -c user.email="$COMMIT_AUTHOR_EMAIL" \ + commit -m "Add $current_tag to CHANGELOG.md [skip ci]" --no-verify --quiet + +echo "INFO: Pushing updates..." +git push "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" master + echo "INFO: Done! Don't forget to thank new contributors :)" diff --git a/.github/actions/trigger-github-release/update-changelog.js b/.github/actions/trigger-github-release/update-changelog.js new file mode 100644 index 0000000000..f7fdd7fbde --- /dev/null +++ b/.github/actions/trigger-github-release/update-changelog.js @@ -0,0 +1,31 @@ +"use strict"; + +const getStdin = require("get-stdin"); +const fs = require("fs").promises; +const path = require("path"); + +const { GITHUB_WORKSPACE } = process.env; + +const INSERTION_POINT = ""; +const CHANGELOG = path.resolve(GITHUB_WORKSPACE, "CHANGELOG.md"); + +main(); +async function main() { + let [stdin, changelog] = await Promise.all([ + getStdin(), + fs.readFile(CHANGELOG, "utf8"), + ]); + + if (!changelog.includes(INSERTION_POINT)) { + throw new Error(`Missing "${INSERTION_POINT}" in CHANGELOG.md`); + } + + // Remove committers + stdin = stdin.split("\n\n#### Committers")[0]; + changelog = changelog.replace( + INSERTION_POINT, + INSERTION_POINT + "\n" + stdin + ); + + await fs.writeFile(CHANGELOG, changelog); +} diff --git a/.github/main.workflow b/.github/main.workflow index bb88d85128..1a6c5a4058 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -7,6 +7,11 @@ action "Trigger GitHub release" { uses = "./.github/actions/trigger-github-release/" secrets = ["GITHUB_TOKEN"] + env = { + COMMIT_AUTHOR_NAME = "Babel Bot" + COMMIT_AUTHOR_EMAIL = "babel@hopeinsource.com" + } + # When GitHub Actions will support the "release" event for public # repositories, we won't need these checks anymore. needs = [ diff --git a/CHANGELOG.md b/CHANGELOG.md index ec87f4f417..b31d200c46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ See [CHANGELOG - v4](/.github/CHANGELOG-v4.md), [CHANGELOG - v5](/.github/CHANGE See [CHANGELOG - 6to5](/.github/CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0.0-beta.29 version changelog. + + + ## v7.3.3 (2019-02-15) #### :eyeglasses: Spec Compliancy