Skip to content

Commit

Permalink
Use a GitHub Action to generate the changelog (#9434) [skip ci]
Browse files Browse the repository at this point in the history
* Use a GitHub Action to generate the changelog

* Update main.workflow [skip ci]
  • Loading branch information
nicolo-ribaudo committed Feb 4, 2019
1 parent 344d35b commit 44d8a59
Show file tree
Hide file tree
Showing 7 changed files with 1,527 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/actions/trigger-github-release/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:10

LABEL "name" = "trigger-github-release"
LABEL "version" = "0.0.1"

LABEL "com.github.actions.name" = "Trigger GitHub release"
LABEL "com.github.actions.description" = "Trigger a new GitHub release and generate the changelog using lerna-changelog."
LABEL "com.github.actions.icon" = "tag"
LABEL "com.github.actions.color" = "yellow"

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

RUN chmod +x /action/entrypoint.sh

ENTRYPOINT ["/action/entrypoint.sh"]
29 changes: 29 additions & 0 deletions .github/actions/trigger-github-release/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

set -e

echo "INFO: Installing action dependencies..."
(cd /action; npm ci)

echo "INFO: Checking out current tag..."
git -c advice.detachedHead=false checkout $GITHUB_REF

echo "INFO: Getting tag info..."
current_tag=$(git describe --abbrev=0 --tags)
last_tag=$(git describe --abbrev=0 --tags HEAD^)
echo "INFO: New version is $current_tag; last version is $last_tag."

echo "INFO: Generating the changelog..."

# lerna-changelog expects the token to be provided as GITHUB_AUTH,
# but GitHub actions don't allow to predefine custom env vars prefixed with
# GITHUB_. We need to define it here.
changelog=$(
GITHUB_AUTH="$GITHUB_TOKEN" \
node /action/node_modules/.bin/lerna-changelog --tag-from $last_tag --tag-to $current_tag
)

echo "INFO: Publishing the new GitHub release..."
echo "$changelog" | node /action/release $current_tag

echo "INFO: Done! Don't forget to thank new contributors :)"
Loading

0 comments on commit 44d8a59

Please sign in to comment.