Skip to content

Commit e833cf7

Browse files
authored
fix(repo): fix pub release ci (#2273)
1 parent 37a9721 commit e833cf7

File tree

3 files changed

+81
-52
lines changed

3 files changed

+81
-52
lines changed

.github/workflows/release_pub.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: release_publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+' # tag-pattern for regular releases
7+
- 'v[0-9]+.[0-9]+.[0-9]+-*' # tag-pattern for pre-releases
8+
workflow_dispatch: # Allow manual triggering of the workflow
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
release:
16+
permissions:
17+
contents: write # Required to creating release
18+
id-token: write # Required for authentication using OIDC
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: 📚 Checkout branch
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
token: ${{ secrets.BOT_GITHUB_API_TOKEN }}
26+
27+
# Set up the Dart SDK and provision the OIDC token used for publishing.
28+
- name: 🎯 Setup Dart
29+
uses: dart-lang/setup-dart@v1
30+
31+
- name: 🐦 Install Flutter
32+
uses: subosito/flutter-action@v2
33+
34+
- name: 📦 Install Tools
35+
run: flutter pub global activate melos
36+
37+
- name: 🔧 Bootstrap Workspace
38+
run: melos bootstrap --verbose
39+
40+
- name: 🌵 Dry Run
41+
run: melos run lint:pub
42+
43+
- name: 📢 Release to pub.dev
44+
run: melos run release:pub
45+
46+
- name: 🏷️ Extract Version Info
47+
id: extract_version
48+
shell: bash
49+
run: |
50+
set -euo pipefail
51+
52+
tag_name="${{ github.ref_name }}"
53+
echo "📦 Tag: $tag_name"
54+
55+
# Check if this is a pre-release (contains hyphen after version)
56+
is_prerelease=$([[ $tag_name == *-* ]] && echo true || echo false)
57+
echo "ℹ️ Pre-release: $is_prerelease"
58+
59+
echo "tag=$tag_name" >> "$GITHUB_OUTPUT"
60+
echo "prerelease=$is_prerelease" >> "$GITHUB_OUTPUT"
61+
62+
- name: 🚀 Create GitHub Release
63+
uses: softprops/action-gh-release@v2
64+
with:
65+
generate_release_notes: true
66+
tag_name: ${{ steps.extract_version.outputs.tag }}
67+
prerelease: ${{ steps.extract_version.outputs.prerelease }}
68+
token: ${{ secrets.BOT_GITHUB_API_TOKEN }}

.github/workflows/release_github.yml renamed to .github/workflows/release_tag.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: release_github
1+
name: release_tag
22

33
on:
44
push:
@@ -13,12 +13,15 @@ jobs:
1313
# Only run this job for commits that indicate a release
1414
if: "${{ startsWith(github.event.head_commit.message, 'chore(repo): release') }}"
1515
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write # Required to create and push tags
1618

1719
steps:
1820
- name: 📚 Checkout branch
1921
uses: actions/checkout@v4
2022
with:
2123
fetch-depth: 0
24+
token: ${{ secrets.BOT_GITHUB_API_TOKEN }}
2225

2326
- name: 🏷️ Extract Version Tag
2427
id: extract_tag
@@ -34,23 +37,20 @@ jobs:
3437
3538
if [[ "$commit_msg" =~ $version_regex ]]; then
3639
version="${BASH_REMATCH[0]}"
37-
is_prerelease=$([[ $version == *-* ]] && echo true || echo false)
38-
3940
echo "✅ Found version tag: $version"
40-
echo "ℹ️ Pre-release: $is_prerelease"
41-
4241
echo "tag=$version" >> "$GITHUB_OUTPUT"
43-
echo "prerelease=$is_prerelease" >> "$GITHUB_OUTPUT"
4442
else
4543
echo "::error ::❌ No SemVer tag found in commit message."
4644
echo "::error ::Expected something like: 'chore(repo): release v1.2.3[-beta]'"
4745
exit 1
4846
fi
4947
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 }}
48+
- name: 🚀 Create and Push Tag
49+
shell: bash
50+
run: |
51+
git config user.name "Stream SDK Bot"
52+
git config user.email "[email protected]"
53+
54+
echo "Creating and pushing tag: ${{ steps.extract_tag.outputs.tag }}"
55+
git tag ${{ steps.extract_tag.outputs.tag }}
56+
git push origin ${{ steps.extract_tag.outputs.tag }}

0 commit comments

Comments
 (0)