Skip to content

Commit c81b6a5

Browse files
committed
add dart release
1 parent 75c9dfc commit c81b6a5

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
concurrency:
30+
group: release-dart-${{ github.ref }}
31+
cancel-in-progress: false
32+
33+
jobs:
34+
publish-dart:
35+
runs-on: ubuntu-latest
36+
if: github.repository == 'apache/fory'
37+
permissions:
38+
contents: read
39+
id-token: write
40+
steps:
41+
- uses: actions/checkout@v5
42+
43+
- uses: actions/setup-python@v6
44+
with:
45+
python-version: '3.11'
46+
cache: 'pip'
47+
48+
- name: Bump Dart package versions for the release tag
49+
shell: bash
50+
run: |
51+
set -euo pipefail
52+
VERSION="${{ github.ref_name }}"
53+
VERSION="${VERSION#v}"
54+
python ci/release.py bump_version -l dart -version "$VERSION"
55+
VERSION="$VERSION" ruby <<'RUBY'
56+
require "yaml"
57+
58+
expected = ENV.fetch("VERSION")
59+
files = [
60+
"dart/pubspec.yaml",
61+
"dart/packages/fory/pubspec.yaml",
62+
"dart/packages/fory-test/pubspec.yaml",
63+
]
64+
65+
files.each do |path|
66+
actual = YAML.load_file(path).fetch("version")
67+
if actual != expected
68+
abort("#{path} version mismatch after bump: expected #{expected}, got #{actual}")
69+
end
70+
end
71+
72+
puts "Verified bumped Dart package versions for #{expected}"
73+
RUBY
74+
75+
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c # v1.7.1
76+
77+
- name: Install Dart package dependencies
78+
shell: bash
79+
working-directory: dart/packages/fory
80+
run: |
81+
set -euo pipefail
82+
dart pub get
83+
84+
- name: Verify publish contents
85+
shell: bash
86+
working-directory: dart/packages/fory
87+
run: |
88+
set -euo pipefail
89+
dart pub publish --dry-run
90+
91+
- name: Publish to pub.dev
92+
shell: bash
93+
working-directory: dart/packages/fory
94+
run: |
95+
set -euo pipefail
96+
dart pub publish --force

ci/release.py

Lines changed: 14 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):
@@ -497,6 +503,14 @@ def _update_pubspec_version(lines, v: str):
497503
return lines
498504

499505

506+
def _update_dart_readme_dependency_version(lines, v: str):
507+
for index, line in enumerate(lines):
508+
if re.match(r"^\s*fory:\s*\^[^\s]+\s*$", line):
509+
lines[index] = f" fory: ^{v}\n"
510+
return lines
511+
raise ValueError("No Dart README dependency snippet for fory found")
512+
513+
500514
def _update_csharp_props_version(lines, v: str):
501515
for index, line in enumerate(lines):
502516
if "<Version>" not in line:

dart/packages/fory/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,6 @@ The main exported API includes:
280280

281281
For the xlang wire format and type mapping details, see the
282282
[Apache Fory specification](https://github.com/apache/fory/tree/main/docs/specification).
283+
284+
For the full Dart guide, see
285+
[https://fory.apache.org/docs/guide/dart/](https://fory.apache.org/docs/guide/dart/).

0 commit comments

Comments
 (0)