-
Notifications
You must be signed in to change notification settings - Fork 2
133 lines (111 loc) · 4.04 KB
/
release.yml
File metadata and controls
133 lines (111 loc) · 4.04 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Release
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version bump type'
required: true
type: choice
options:
- patch
- minor
- major
default: 'minor'
permissions:
contents: write
pull-requests: write
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Install dependencies
run: npm ci
- name: Run tests
run: |
npx tsc --noEmit
npm run build
npm test
- name: Bump version
id: version
run: |
OLD_VERSION=$(node -p "require('./package.json').version")
npm version ${{ inputs.version_type }} --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")
echo "old_version=$OLD_VERSION" >> $GITHUB_OUTPUT
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Update CHANGELOG
run: |
# Move [Unreleased] to new version section
NEW_VERSION="${{ steps.version.outputs.new_version }}"
DATE=$(date +%Y-%m-%d)
# Create temp file with updated changelog
awk -v ver="$NEW_VERSION" -v date="$DATE" '
/## \[Unreleased\]/ {
print $0
print ""
print "## [" ver "] - " date
next
}
{ print }
' CHANGELOG.md > CHANGELOG.tmp
mv CHANGELOG.tmp CHANGELOG.md
- name: Commit changes
run: |
git add package.json package-lock.json CHANGELOG.md
git commit -m "chore(release): ${{ steps.version.outputs.new_version }}"
git tag ${{ steps.version.outputs.tag }}
- name: Push changes
run: |
git push origin main
git push origin ${{ steps.version.outputs.tag }}
- name: Extract changelog for this version
id: changelog
run: |
# Extract changelog content between current version and previous version
VERSION="${{ steps.version.outputs.new_version }}"
CHANGELOG=$(awk "/## \[$VERSION\]/,/## \[/" CHANGELOG.md | head -n -1 | tail -n +2)
# Use multiline output
echo "content<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version.outputs.tag }}
release_name: Release ${{ steps.version.outputs.tag }}
body: |
## What's Changed
${{ steps.changelog.content }}
## Installation
```bash
npm install @taskgenius/calendar@${{ steps.version.outputs.new_version }}
```
**Full Changelog**: https://github.com/taskgenius/calendar/compare/v${{ steps.version.outputs.old_version }}...${{ steps.version.outputs.tag }}
draft: false
prerelease: false
- name: Summary
run: |
echo "## 🚀 Release Created Successfully!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Version**: ${{ steps.version.outputs.old_version }} → ${{ steps.version.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
echo "**Tag**: ${{ steps.version.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "The package will be automatically published to npm when the tag is pushed." >> $GITHUB_STEP_SUMMARY