-
-
Notifications
You must be signed in to change notification settings - Fork 6
64 lines (55 loc) · 1.96 KB
/
prepare-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
61
62
63
64
name: Prepare Release
on:
push:
branches:
- "major/*"
- "minor/*"
- "patch/*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
prepare-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
env:
GITHUB_TOKEN: ${{ secrets.CUSTOM_ACCESS_TOKEN }}
- name: Extract version from branch name
id: extract_version
run: |
BRANCH="${GITHUB_REF#refs/heads/}"
if [[ "$BRANCH" =~ ^(major|minor|patch)/v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
NEW_VERSION="${BASH_REMATCH[2]}"
echo "Extracted version: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
else
echo "Branch name does not contain a valid version number"
exit 1
fi
- name: Update version in pubspec.yaml
run: |
NEW_VERSION="${{ steps.extract_version.outputs.new_version }}"
sed -i "s/^version: .*/version: $NEW_VERSION/" pubspec.yaml
- name: Create tag
env:
GITHUB_TOKEN: ${{ secrets.CUSTOM_ACCESS_TOKEN }}
run: |
NEW_VERSION="${{ steps.extract_version.outputs.new_version }}"
git config user.name thedevsbuddy
git config user.email [email protected]
git add pubspec.yaml
git commit -m "Bump version to $NEW_VERSION"
git tag "v$NEW_VERSION"
git push origin "v$NEW_VERSION"
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.CUSTOM_ACCESS_TOKEN }}
run: |
NEW_VERSION="${{ steps.extract_version.outputs.new_version }}"
gh release create "v$NEW_VERSION" \
--title "Release $NEW_VERSION" \
--notes "Release notes for version $NEW_VERSION
For full changelog, see [CHANGELOG.md](./CHANGELOG.md)"