Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
ci(GITHUB): adopt changelog script
Browse files Browse the repository at this point in the history
  • Loading branch information
niall-byrne committed Jul 19, 2022
1 parent 59c556e commit c872281
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 21 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/self-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,8 @@ jobs:

- name: Create Release -- Generate Changelog
if: contains(github.ref, '/tags/v')
uses: scottbrenner/[email protected]
id: Changelog
env:
REPO: ${{ github.repository }}
run:
source ./{{cookiecutter.project_slug}}/.github/scripts/changelog.sh

- name: Create Release -- Create Github Release
if: contains(github.ref, '/tags/v')
Expand All @@ -225,9 +223,8 @@ jobs:
tag_name: ${{ env.BRANCH_OR_TAG }}
release_name: Release ${{ env.BRANCH_OR_TAG }}
body: |
${{ steps.Changelog.outputs.changelog }}
${{ env.CHANGE_LOG_CONTENT }}
## Deployment Checklist
- [ ] Ensure correct version is notated
- [ ] Ensure documentation is accurate
- [ ] Ensure git commits are properly formatted
draft: true
Expand Down
1 change: 0 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"company": "Shared Vision Solutions",
"email": "[email protected]",
"_GITHUB_ACTION_MARKDOWN_LINK_CHECK": "gaurav-nelson/[email protected]",
"_GITHUB_GENERATE_CHANGELOG_ACTION": "scottbrenner/[email protected]",
"_GITHUB_GITLEAKS_ACTION": "zricethezav/[email protected]",
"_GITHUB_PUSH_ACTION": "ad-m/[email protected]"
}
21 changes: 21 additions & 0 deletions {{cookiecutter.project_slug}}/.github/scripts/changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -eo pipefail

main() {

echo "{}" > package.json
TAG="$(git tag | sort --version-sort | tail -n 2 | head -n 1)"
CHANGE_LOG_CONTENT="$(npx -q generate-changelog -f - -t "${TAG}")"

{
echo "CHANGE_LOG_CONTENT<<EOF"
echo "${CHANGE_LOG_CONTENT}"
echo "EOF"
} >> "$GITHUB_ENV"

rm package.json

}

main
12 changes: 7 additions & 5 deletions {{cookiecutter.project_slug}}/.github/scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#!/bin/bash

# shellcheck disable=SC2129

set -eo pipefail

main() {
BRANCH_OR_TAG="$(echo "${GITHUB_REF}" | sed 's/refs\/heads\///g' | sed 's/refs\/tags\///g')"
WORKFLOW_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
echo "BRANCH_OR_TAG=${BRANCH_OR_TAG}" >> "$GITHUB_ENV"
echo "WEBHOOK_URL=${WEBHOOK_URL}" >> "$GITHUB_ENV"
echo "NOTIFICATION=${PROJECT_NAME} [<${WORKFLOW_URL}|${BRANCH_OR_TAG}>]" >> "$GITHUB_ENV"

{
echo "BRANCH_OR_TAG=${BRANCH_OR_TAG}"
echo "WEBHOOK_URL=${WEBHOOK_URL}"
echo "NOTIFICATION=${PROJECT_NAME} [<${WORKFLOW_URL}|${BRANCH_OR_TAG}>]"
} >> "$GITHUB_ENV"

}

main
15 changes: 6 additions & 9 deletions {{cookiecutter.project_slug}}/.github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,15 @@ jobs:
if: contains(github.ref, '/tags/v')
run: |
source ./.github/scripts/setup.sh
echo "{}" > package.json
env:
WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Release -- Generate Changelog
- name: Create Release -- Generate Changelog
if: contains(github.ref, '/tags/v')
uses: {% endraw %}{{ cookiecutter._GITHUB_GENERATE_CHANGELOG_ACTION }}{% raw %}
id: Changelog
env:
REPO: ${{ github.repository }}
run:
source ./.github/scripts/changelog.sh

- name: Release -- Create Github Release
- name: Create Release -- Create Github Release
if: contains(github.ref, '/tags/v')
uses: actions/create-release@v1
env:
Expand All @@ -52,11 +49,11 @@ jobs:
tag_name: ${{ env.BRANCH_OR_TAG }}
release_name: Release ${{ env.BRANCH_OR_TAG }}
body: |
${{ steps.Changelog.outputs.changelog }}
${{ env.CHANGE_LOG_CONTENT }}
draft: true
prerelease: false

- name: Release -- Report Job Status (Success)
- name: Create Release -- Report Job Status (Success)
if: contains(github.ref, '/tags/v')
run: |
./.github/scripts/notifications.sh "${NOTIFICATION}" ":white_check_mark: automated release has been created:\nhttps://github.com/${USERNAME}/${PROJECT_NAME}/releases"
Expand Down

0 comments on commit c872281

Please sign in to comment.