-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (80 loc) · 3.67 KB
/
prepare.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
83
84
85
86
87
88
89
90
91
92
93
94
##.title
## ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
##
## Dart/Flutter (DF) Packages by DevCetra.com & contributors. The use of this
## source code is governed by an MIT-style license described in the LICENSE
## file located in this project's root directory.
##
## See: https://opensource.org/license/mit
##
## ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
##.title~
name: Prepare version
## -----------------------------------------------------------------------------
on:
push:
branches:
- main
## -----------------------------------------------------------------------------
jobs:
prepare:
runs-on: ubuntu-latest
steps:
# Checkout the code from the repository
- name: Checkout code
uses: actions/checkout@v3
# Get the latest commit message
- name: Get commit messages
id: get_commits
run: |
COMMIT_MESSAGES=$(git log --format=%B -n 1 HEAD)
echo "::set-output name=COMMIT_MESSAGES::${COMMIT_MESSAGES}"
# Check if the commit message starts with '+'
- name: Check commit message
id: check_message
run: |
if echo "${{ steps.get_commits.outputs.COMMIT_MESSAGES }}" | grep -q "^+"; then
echo "::set-output name=PROCEED::true"
else
echo "::set-output name=PROCEED::false"
fi
# Debug environment variables
- name: Debug environment variables
run: |
echo "PROCEED=${{ steps.check_message.outputs.PROCEED }}"
echo "COMMIT_MESSAGES=${{ steps.get_commits.outputs.COMMIT_MESSAGES }}"
# Set up Dart if the commit message check passed
- name: Set up Dart
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
uses: dart-lang/setup-dart@v1.2
# Format Dart code if the commit message check passed
- name: Format Dart code
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
run: dart format .
# Apply Dart fixes if the commit message check passed
- name: Apply Dart fixes
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
run: dart fix --apply
# Extract the version from pubspec.yaml if the commit message check passed
- name: Extract version from pubspec.yaml
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
id: get_version
run: |
VERSION=$(grep "version:" pubspec.yaml | sed 's/version: //')
echo "Version extracted from pubspec.yaml: $VERSION"
echo "::set-output name=PUBSPEC_VERSION::${VERSION}"
# Update CHANGELOG.md if the commit message check passed
- name: Update CHANGELOG.md
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
run: |
RELEASE_NOTES="${{ steps.get_commits.outputs.COMMIT_MESSAGES }}"
dart run .github/scripts/update_changelog.dart "${{ steps.get_version.outputs.PUBSPEC_VERSION }}" "$RELEASE_NOTES"
# Commit and push changes if the commit message check passed
- name: Commit and push changes
if: ${{ steps.check_message.outputs.PROCEED == 'true' }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Prepare version ${{ steps.get_version.outputs.PUBSPEC_VERSION }}"
git push