forked from monken/cfn-include
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (54 loc) · 1.96 KB
/
release.yml
File metadata and controls
63 lines (54 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# TODO: ENABLE / UNCOMMENT WHEN NPM_TOKEN IS SET in secrets REPO
name: release
on:
push:
branches: ["master"]
paths-ignore:
- '.devcontainer/**'
tags-ignore: ['**']
jobs:
tests:
uses: ./.github/workflows/tests.yml
tag-release:
runs-on: ubuntu-latest
needs: [tests]
steps:
- uses: actions/checkout@v4
with:
# important, must be defined on checkout to kick publish
token: ${{ secrets.GH_TOKEN }}
# Full history needed for conventional-changelog to detect breaking changes
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: tag release
run: |
# ignore if commit message is chore(release): ...
if [[ $(git log -1 --pretty=%B) =~ ^chore\(release\):.* ]]; then
echo "Commit message starts with 'chore(release):', skipping release"
exit 0
fi
git config --local user.email "creadbot@github.com"
git config --local user.name "creadbot_github"
npm install
# Check for breaking changes in commits since last tag
# Look for feat!:, fix!:, or BREAKING CHANGE in commit messages
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
RANGE="$LAST_TAG..HEAD"
else
RANGE="HEAD"
fi
# Check all commits (not just first-parent) for breaking changes
if git log $RANGE --format="%B" | grep -qE "(^[a-z]+!:|BREAKING CHANGE:)"; then
echo "Breaking change detected, forcing major version bump"
npx commit-and-tag-version --release-as major
else
npx commit-and-tag-version
fi
# Pull any commits that landed during the test phase (e.g. dependabot merges)
git pull --rebase origin master
git push
git push --tags