Skip to content

Commit 9fc0f6f

Browse files
authored
feat(repo): add workflow for automatic release (#2271)
1 parent 3b3241a commit 9fc0f6f

File tree

3 files changed

+101
-6
lines changed

3 files changed

+101
-6
lines changed

.github/workflows/release_github.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: release_github
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
release:
13+
# Only run this job for commits that indicate a release
14+
if: "${{ startsWith(github.event.head_commit.message, 'chore(repo): release') }}"
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: 📚 Checkout branch
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: 🏷️ Extract Version Tag
24+
id: extract_tag
25+
shell: bash
26+
run: |
27+
set -euo pipefail
28+
29+
commit_msg="${{ github.event.head_commit.message }}"
30+
echo "📦 Commit message: $commit_msg"
31+
32+
# Match vX.Y.Z or vX.Y.Z-suffix (case-insensitive)
33+
version_regex='[vV][0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.\-]+)?'
34+
35+
if [[ "$commit_msg" =~ $version_regex ]]; then
36+
version="${BASH_REMATCH[0]}"
37+
is_prerelease=$([[ $version == *-* ]] && echo true || echo false)
38+
39+
echo "✅ Found version tag: $version"
40+
echo "ℹ️ Pre-release: $is_prerelease"
41+
42+
echo "tag=$version" >> "$GITHUB_OUTPUT"
43+
echo "prerelease=$is_prerelease" >> "$GITHUB_OUTPUT"
44+
else
45+
echo "::error ::❌ No SemVer tag found in commit message."
46+
echo "::error ::Expected something like: 'chore(repo): release v1.2.3[-beta]'"
47+
exit 1
48+
fi
49+
50+
- name: 🚀 Create GitHub Release
51+
uses: softprops/action-gh-release@v1
52+
with:
53+
generate_release_notes: true
54+
tag_name: ${{ steps.extract_tag.outputs.tag }}
55+
prerelease: ${{ steps.extract_tag.outputs.prerelease }}
56+
token: ${{ secrets.BOT_GITHUB_API_TOKEN }}

.github/workflows/release_pub.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: release_pub
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
release:
13+
permissions:
14+
id-token: write # Required for authentication using OIDC
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: 📚 Checkout branch
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
# Set up the Dart SDK and provision the OIDC token used for publishing.
23+
- name: 🎯 Setup Dart
24+
uses: dart-lang/setup-dart@v1
25+
26+
- name: 🐦 Install Flutter
27+
uses: subosito/flutter-action@v2
28+
29+
- name: 📦 Install Tools
30+
run: flutter pub global activate melos
31+
32+
- name: 🔧 Bootstrap Workspace
33+
run: melos bootstrap --verbose
34+
35+
- name: 🌵 Dry Run
36+
run: melos run lint:pub
37+
38+
- name: 🚀 Release to pub.dev
39+
run: melos run release:pub

melos.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,8 @@ scripts:
149149
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
150150
151151
lint:pub:
152-
run: |
153-
melos exec -c 5 --no-private --ignore="*example*" -- \
154-
flutter pub publish --dry-run
155-
description: |
156-
Run `pub publish --dry-run` in all packages.
157-
- Note: you can also rely on your IDEs Dart Analysis / Issues window.
152+
run: melos exec -c 1 --no-published --no-private --order-dependents -- "flutter pub publish -n"
153+
description: Dry run `pub publish` in all packages.
158154

159155
generate:all:
160156
run: melos run generate:dart && melos run generate:flutter
@@ -206,3 +202,7 @@ scripts:
206202
description: Removes all the ignored files from the coverage report.
207203
packageFilters:
208204
dirExists: coverage
205+
206+
release:pub:
207+
run: melos exec -c 1 --no-published --no-private --order-dependents -- "flutter pub publish -f"
208+
description: Publish all packages to pub.dev.

0 commit comments

Comments
 (0)