Skip to content

Commit 42c4f29

Browse files
committed
auto dart release
1 parent 75c9dfc commit 42c4f29

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Publish Dart
19+
run-name: "Dart Release: ${{ github.ref_name }}"
20+
21+
on:
22+
push:
23+
tags: ['v*']
24+
25+
permissions:
26+
contents: read
27+
id-token: write
28+
29+
jobs:
30+
publish-dart:
31+
runs-on: ubuntu-latest
32+
if: github.repository == 'apache/fory'
33+
permissions:
34+
id-token: write
35+
steps:
36+
- uses: actions/checkout@v5
37+
38+
- uses: actions/setup-python@v5
39+
with:
40+
python-version: '3.11'
41+
42+
- name: Bump dart version
43+
shell: bash
44+
run: |
45+
set -euo pipefail
46+
VERSION="${{ github.ref_name }}"
47+
VERSION="${VERSION#v}"
48+
python ci/release.py bump_version -l dart -version "$VERSION"
49+
50+
- uses: dart-lang/setup-dart@v1
51+
52+
- name: Publish to pub.dev
53+
working-directory: dart/packages/fory
54+
run: dart pub publish --force

ci/release.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@ def bump_dart_version(new_version):
293293
"dart/packages/fory-test",
294294
]:
295295
_bump_version(p, "pubspec.yaml", new_version, _update_pubspec_version)
296+
_bump_version(
297+
"dart/packages/fory",
298+
"README.md",
299+
new_version,
300+
_update_dart_readme_dependency_version,
301+
)
296302

297303

298304
def bump_compiler_version(new_version):
@@ -523,6 +529,18 @@ def _update_csharp_readme_package_version(lines, v: str):
523529
raise ValueError("No Apache.Fory PackageReference version snippet found")
524530

525531

532+
def _update_dart_readme_dependency_version(lines, v: str):
533+
for index, line in enumerate(lines):
534+
if re.match(r"^\s*fory\s*:\s*\^\d+\.\d+\.\d+", line):
535+
lines[index] = re.sub(
536+
r"(fory\s*:\s*\^)\d+\.\d+\.\d+\S*",
537+
r"\g<1>" + v,
538+
line,
539+
)
540+
return lines
541+
raise ValueError("No fory dependency version snippet found in Dart README")
542+
543+
526544
def _update_swift_readme_dependency_version(lines, v: str):
527545
for index, line in enumerate(lines):
528546
if "https://github.com/apache/fory.git" not in line:

0 commit comments

Comments
 (0)