-
Notifications
You must be signed in to change notification settings - Fork 1.1k
60 lines (53 loc) · 2.08 KB
/
auto-release.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
name: Update Version and Changelog and Readme
on:
release:
types: [published]
jobs:
update-version-and-changelog:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get latest release info
id: get_release
uses: actions/github-script@v6
with:
script: |
const release = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
});
core.setOutput('tag_name', release.data.tag_name);
core.setOutput('body', release.data.body);
- name: Update version file
run: echo ${{ steps.get_release.outputs.tag_name }} > web/.version
- name: Update CHANGELOG.md
run: |
echo "# Changelog" > CHANGELOG.md.new
echo "" >> CHANGELOG.md.new
echo "## ${{ steps.get_release.outputs.tag_name }}" >> CHANGELOG.md.new
echo "" >> CHANGELOG.md.new
echo "${{ steps.get_release.outputs.body }}" >> CHANGELOG.md.new
echo "" >> CHANGELOG.md.new
if [ -f CHANGELOG.md ]; then
sed '1,2d' CHANGELOG.md >> CHANGELOG.md.new
fi
mv CHANGELOG.md.new CHANGELOG.md
- name: Update README.md
run: |
sed -i 's|https://img.shields.io/badge/version-.*-informational|https://img.shields.io/badge/version-${{ steps.get_release.outputs.tag_name }}-informational|g' README.md
- name: Commit and push changes
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add web/.version CHANGELOG.md README.md
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "reNgine release: ${{ steps.get_release.outputs.tag_name }} :rocket:"
git push origin HEAD:${{ github.event.repository.default_branch }}
fi