-
-
Notifications
You must be signed in to change notification settings - Fork 6
74 lines (61 loc) · 2.38 KB
/
prepare-release.yml
File metadata and controls
74 lines (61 loc) · 2.38 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
name: ⚙️ Prepare Release
on:
push:
branches:
- "release/*"
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" =~ ^(release)/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: 🎉 Commit and push to branch and tag
env:
GITHUB_TOKEN: ${{ secrets.CUSTOM_ACCESS_TOKEN }}
run: |
NEW_VERSION="${{ steps.extract_version.outputs.new_version }}"
TARGET_BRANCH="${GITHUB_REF#refs/heads/}"
# Configure Git
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Ensure we are on the correct branch
git checkout $TARGET_BRANCH
# Commit changes
git add pubspec.yaml
git commit -m "Bump version to $NEW_VERSION"
# Push changes to the branch
git push origin $TARGET_BRANCH
# Tag the commit and push the tag
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)"
# Explicitly run our release workflow for this new tag
gh workflow run publish-release.yml --ref "v$NEW_VERSION"