-
Notifications
You must be signed in to change notification settings - Fork 3
91 lines (82 loc) · 3.03 KB
/
Copy pathrelease-pr.yml
File metadata and controls
91 lines (82 loc) · 3.03 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
name: Release PR
on:
push:
branches: [main]
# Ignore files exclusively touched by the release/next merge to avoid
# racing with release.yml. Side effect: a PR that only changes pubspec.yaml
# (e.g. a dependency bump) won't immediately refresh the release PR, but
# the daily cron covers it within 24 hours and no commits are ever lost.
paths-ignore:
- pubspec.yaml
- CHANGELOG.md
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
release-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compute next version
id: version
run: |
YEAR=$(date +'%Y')
MONTH=$(date +'%-m')
LATEST=$(git tag --list "v${YEAR}.${MONTH}.*" | sort -V | tail -1)
if [ -z "$LATEST" ]; then
PATCH=0
else
PATCH=$(echo "$LATEST" | sed "s/v${YEAR}\\.${MONTH}\\.//")
PATCH=$((PATCH + 1))
fi
VERSION="${YEAR}.${MONTH}.${PATCH}"
# Keep Android versionCode unique even for multiple releases on the same day.
# Formula: YYYYMMDD * 100 + patch (e.g. 20260517 * 100 + 7 = 2026051707)
BUILD=$(( $(date +'%Y%m%d') * 100 + PATCH ))
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=v${VERSION}" >> $GITHUB_OUTPUT
echo "pubspec_version=${VERSION}+${BUILD}" >> $GITHUB_OUTPUT
- name: Generate release notes
id: cliff
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --unreleased --tag ${{ steps.version.outputs.tag }}
env:
OUTPUT: release-notes.md
- name: Check for releasable content
id: check
run: |
# Skip if git-cliff produced no version section (only header/footer)
if grep -q '^## \[' release-notes.md 2>/dev/null; then
echo "has_content=true" >> $GITHUB_OUTPUT
else
echo "has_content=false" >> $GITHUB_OUTPUT
fi
- name: Update CHANGELOG.md
if: steps.check.outputs.has_content == 'true'
run: |
# Prepend new section; touch ensures the file exists on first run
touch CHANGELOG.md
cat release-notes.md CHANGELOG.md > changelog.tmp
mv changelog.tmp CHANGELOG.md
- name: Update pubspec.yaml version
if: steps.check.outputs.has_content == 'true'
run: |
sed -i "s/^version: .*/version: ${{ steps.version.outputs.pubspec_version }}/" pubspec.yaml
- name: Create or update release PR
if: steps.check.outputs.has_content == 'true'
uses: peter-evans/create-pull-request@v7
with:
branch: release/next
base: main
title: 'Release ${{ steps.version.outputs.version }}'
body-path: release-notes.md
commit-message: 'chore: prepare release ${{ steps.version.outputs.version }}'
delete-branch: false