Update CHAMGELOG.md using the "Trigger GitHub release" action (#9561)
Update CHANGELOG.md using the "Trigger GitHub release" action
This commit is contained in:
parent
fc1ea7f496
commit
4540f2653b
@ -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
|
||||
|
||||
|
||||
@ -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 :)"
|
||||
|
||||
31
.github/actions/trigger-github-release/update-changelog.js
vendored
Normal file
31
.github/actions/trigger-github-release/update-changelog.js
vendored
Normal file
@ -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 = "<!-- insert-new-changelog-here -->";
|
||||
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);
|
||||
}
|
||||
5
.github/main.workflow
vendored
5
.github/main.workflow
vendored
@ -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 = [
|
||||
|
||||
@ -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.
|
||||
|
||||
<!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
|
||||
<!-- insert-new-changelog-here -->
|
||||
|
||||
## v7.3.3 (2019-02-15)
|
||||
|
||||
#### :eyeglasses: Spec Compliancy
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user