-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (76 loc) · 2.4 KB
/
bump.yml
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
name: Bump version
on:
workflow_dispatch:
inputs:
semver:
description: "Which SemVer"
required: true
default: "patch"
type: choice
options:
- major
- minor
- patch
workflow_call:
inputs:
semver:
description: The image_name to build for.
required: true
type: string
jobs:
bump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: generate new version and save to env variable
uses: actions/github-script@v7
id: github_releases
with:
result-encoding: string
script: |
const release = await github.rest.repos.getLatestRelease(
{
owner: context.repo.owner,
repo: context.repo.repo,
}
);
return release.data.tag_name;
- name: semver
id: get_version
run: echo "NEW_VERSION=$(docker run --rm alpine/semver semver -c -i ${{ inputs.semver }} ${{ steps.github_releases.outputs.result }})" >> "$GITHUB_OUTPUT"
- name: Generate release notes
uses: actions/github-script@v7
id: get_release_note
env:
NEW_VERSION: ${{steps.get_version.outputs.NEW_VERSION}}
with:
result-encoding: string
script: |
const notes = await github.rest.repos.generateReleaseNotes(
{
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `v${process.env.NEW_VERSION}`,
}
);
return notes.data.body;
- run: |
cat << EOF >> new
## v${{ steps.get_version.outputs.NEW_VERSION }} ($(date '+%Y-%m-%d'))
${{ steps.get_release_note.outputs.result }}
EOF
- run: cat new ./CHANGELOG.md > temp
- run: mv temp ./CHANGELOG.md
- run: rm new
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
base: main
branch: release
commit-message: "bump: v${{ steps.get_version.outputs.NEW_VERSION }}"
body: ${{ steps.get_release_note.outputs.result }}
title: "chore: bump v${{ steps.get_version.outputs.NEW_VERSION }}"
labels: |
documentation
draft: true
milestone: "v${{ steps.get_version.outputs.NEW_VERSION }}"