forked from rrwick/Bandage
-
Notifications
You must be signed in to change notification settings - Fork 15
94 lines (81 loc) · 2.75 KB
/
auto-release.yml
File metadata and controls
94 lines (81 loc) · 2.75 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
name: Automated Release
on:
workflow_dispatch:
schedule:
- cron: "0 12 1 * *" # At 12:00 on day-of-month 1
jobs:
build:
runs-on: ubuntu-latest
# Check if the event is not triggered by a fork
if: ${{ github.repository == 'asl/BandageNG' && github.ref == 'refs/heads/dev' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Fetch all history for all branches and tags
fetch-depth: 0
- name: Get next version
uses: reecetech/version-increment@2024.10.1
id: version
with:
scheme: calver
- name: Update version
run: echo "${{ steps.version.outputs.version }}" > VERSION.txt
- name: Get changelog
id: changelog
run: |
TAG="$(git describe --tags --abbrev=0)"
GIT_LOG="$(git log $TAG..HEAD --oneline --pretty=format:"- %s [%an]")"
CHANGELOG=$(cat << EOF
Changelog:
$GIT_LOG
EOF
)
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
CHANGELOG="${CHANGELOG//'#'/''}"
echo "::set-output name=content::$CHANGELOG"
- name: Display changelog
run: echo "${{ steps.changelog.outputs.content }}"
- name: Get version
run: |
VERSION="$(cat VERSION.txt)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Get commit message
id: message
run: |
COMMIT_MSG=$(cat << EOF
Release v${{ env.VERSION }}
${{ steps.changelog.outputs.content }}
EOF
)
COMMIT_MSG="${COMMIT_MSG//'%'/'%25'}"
COMMIT_MSG="${COMMIT_MSG//$'\n'/'%0A'}"
COMMIT_MSG="${COMMIT_MSG//$'\r'/'%0D'}"
echo "::set-output name=content::$COMMIT_MSG"
- name: Get pull request body message
id: body
run: |
MSG=$(cat << EOF
Auto-generated pull request for version ${{ env.VERSION }}.
Please use **Squash and merge** to include the changelog in the release message.
${{ steps.changelog.outputs.content }}
EOF
)
MSG="${MSG//'%'/'%25'}"
MSG="${MSG//$'\n'/'%0A'}"
MSG="${MSG//$'\r'/'%0D'}"
echo "::set-output name=content::$MSG"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
base: dev
add-paths: VERSION.txt
reviewers: asl
commit-message: ${{ steps.message.outputs.content }}
signoff: false
branch: v${{ env.VERSION }}
delete-branch: true
title: Automated Release v${{ env.VERSION }}
body: ${{ steps.body.outputs.content }}