Skip to content

Commit 4a10a45

Browse files
committed
build(ci): add release workflow and improve CI configuration
- Rename build.yaml to ci.yaml for clarity - Add automated release workflow with pub.dev publishing and GitHub releases - Update README badge to reference new ci.yaml workflow - Simplify example analysis_options.yaml - Add explicit void return type to thenAnswerMany extension method
1 parent 3b18a87 commit 4a10a45

File tree

5 files changed

+86
-32
lines changed

5 files changed

+86
-32
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build
1+
name: CI
22
on:
33
push:
44
branches: [ main ]
@@ -18,10 +18,12 @@ jobs:
1818
- name: Get dependencies
1919
run: flutter pub get
2020
- name: Check code formatting
21-
run: dart format . --set-exit-if-changed
22-
- name: Unit tests
21+
run: dart format --output=none --set-exit-if-changed .
22+
- name: Static code analysis
23+
run: flutter analyze --no-pub --no-congratulate
24+
- name: Run unit tests
2325
run: make test
2426
- name: Upload coverage reports to Codecov
2527
uses: codecov/[email protected]
2628
with:
27-
token: ${{ secrets.CODECOV_TOKEN }}
29+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/release.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
publish:
10+
permissions:
11+
id-token: write
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout the code
15+
uses: actions/checkout@v4
16+
- name: Set up Flutter
17+
uses: subosito/flutter-action@v2
18+
- name: Get dependencies
19+
run: flutter pub get
20+
- name: Check code formatting
21+
run: dart format --output=none --set-exit-if-changed .
22+
- name: Static code analysis
23+
run: flutter analyze --no-pub --no-congratulate
24+
- name: Run unit tests
25+
run: flutter test --no-pub --test-randomize-ordering-seed=random
26+
27+
- name: Verify pubspec.yaml version matches tag
28+
run: |
29+
TAG=${GITHUB_REF#refs/tags/v}
30+
PUBSPEC_VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //')
31+
if [ "$PUBSPEC_VERSION" != "$TAG" ]; then
32+
echo "Error: pubspec.yaml version ($PUBSPEC_VERSION) does not match tag version ($TAG)"
33+
exit 1
34+
fi
35+
echo "✓ Version validated: $PUBSPEC_VERSION"
36+
37+
- name: Dry run publish
38+
run: dart pub publish --dry-run
39+
40+
- name: Setup Dart SDK for OIDC authentication
41+
uses: dart-lang/setup-dart@v1
42+
43+
- name: Publish to pub.dev
44+
run: dart pub publish --force
45+
46+
release:
47+
needs: publish
48+
runs-on: ubuntu-latest
49+
permissions:
50+
contents: write
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v4
54+
55+
- name: Extract version from tag
56+
id: get_version
57+
run: |
58+
TAG=${GITHUB_REF#refs/tags/v}
59+
echo "version=$TAG" >> $GITHUB_OUTPUT
60+
61+
- name: Extract changelog for version
62+
id: changelog
63+
run: |
64+
VERSION="${{ steps.get_version.outputs.version }}"
65+
# Extract changelog content for this version
66+
awk "/## $VERSION/{flag=1; next} /^## /{flag=0} flag" CHANGELOG.md > release_notes.md
67+
68+
- name: Create GitHub Release
69+
uses: softprops/action-gh-release@v2
70+
with:
71+
tag_name: ${{ github.ref }}
72+
name: Release v${{ steps.get_version.outputs.version }}
73+
body_path: release_notes.md
74+
draft: false
75+
prerelease: false
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<img alt="Pub Package" src="https://tinyurl.com/5cw9f9fm">
1111
</a>
1212
<a href="https://github.com/Nikoro/system_date_time_format_hook/actions">
13-
<img alt="Build Status" src="https://github.com/Nikoro/system_date_time_format_hook/actions/workflows/build.yaml/badge.svg">
13+
<img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/Nikoro/system_date_time_format_hook/ci.yaml?label=build">
1414
</a>
1515
<a href="https://codecov.io/gh/Nikoro/system_date_time_format_hook">
1616
<img alt="Code Coverage" src="https://codecov.io/gh/Nikoro/system_date_time_format_hook/branch/main/graph/badge.svg">
@@ -21,7 +21,7 @@
2121
<img alt="Android support ✓" src="https://img.shields.io/badge/%E2%9C%93-grey?logo=android">
2222
<img alt="iOS support ✓" src="https://img.shields.io/badge/%E2%9C%93-grey?logo=ios">
2323
<img alt="macOS support ✓" src="https://tinyurl.com/kka6pu4c">
24-
<img alt="windows support ✓" src="https://img.shields.io/badge/%E2%9C%93-grey?logo=windows">
24+
<img alt="windows support ✓" src="https://tinyurl.com/3heeby4v">
2525
<img alt="linux support ✓" src="https://img.shields.io/badge/%E2%9C%93-grey?logo=linux">
2626
<img alt="web support ✓" src="https://img.shields.io/badge/web%20%E2%9C%93-grey">
2727
</p>

example/analysis_options.yaml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,3 @@
1-
# This file configures the analyzer, which statically analyzes Dart code to
2-
# check for errors, warnings, and lints.
3-
#
4-
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5-
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6-
# invoked from the command line by running `flutter analyze`.
7-
8-
# The following line activates a set of recommended lints for Flutter apps,
9-
# packages, and plugins designed to encourage good coding practices.
101
include: package:flutter_lints/flutter.yaml
112

12-
linter:
13-
# The lint rules applied to this project can be customized in the
14-
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15-
# included above or to enable additional rules. A list of all available lints
16-
# and their documentation is published at https://dart.dev/lints.
17-
#
18-
# Instead of disabling a lint rule for the entire project in the
19-
# section below, it can also be suppressed for a single line of code
20-
# or a specific dart file by using the `// ignore: name_of_lint` and
21-
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22-
# producing the lint.
23-
rules:
24-
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25-
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
263

27-
# Additional information about this file can be found at
28-
# https://dart.dev/guides/language/analysis-options

test/_tools/extensions/mocktail_extensions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
part of 'extensions.dart';
22

33
extension WhenExtension<T> on When<T> {
4-
thenAnswerMany(List<Answer<T>> cbs) {
4+
void thenAnswerMany(List<Answer<T>> cbs) {
55
return thenAnswer((invocation) {
66
if (cbs.isEmpty) throw "No more answers available";
77
return cbs.removeAt(0)(invocation);

0 commit comments

Comments
 (0)