-
Notifications
You must be signed in to change notification settings - Fork 3
63 lines (59 loc) · 2.37 KB
/
release-drafter.yaml
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
name: "📝 Release Drafter"
on:
push:
branches:
- main
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
pull_request_target:
types: [opened, reopened, synchronize]
permissions:
contents: read
jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
outputs:
next-version: ${{ steps.release-drafter.outputs.next-version }}
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter-config.yaml
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Update package.json version to match the release draft version
- name: Update package.json version
run: |
if test -f .release-drafter/next-version; then
draft_version=$(cat .release-drafter/next-version)
current_version=$(grep -oP '(?<="version": ")[^"]+' package.json)
if [ "$draft_version" != "$current_version" ]; then
echo "Updating package.json to version ${draft_version}..."
sed -i.bak "s/\"version\": \".*\"/\"version\": \"${draft_version}\"/" package.json
rm package.json.bak
else
echo "Package.json version already matches next release draft version"
fi
else
echo ".release-drafter/next-version file not found, skipping package.json update"
exit 0
fi
# Commit the updated package.json and push the changes to the repository
- name: Commit and push package.json changes
run: |
if test -f .release-drafter/next-version; then
git add package.json
git commit -m "Update package.json version to ${draft_version}"
git push origin HEAD:${{ github.head_ref }}
else
echo ".release-drafter/next-version file not found, skipping package.json update"
fi