Skip to content

Commit a790725

Browse files
committed
ci: replace build workflow with enhanced CI/CD pipelines
- Remove legacy build.yaml workflow - Add comprehensive ci.yaml workflow with formatting and analysis checks - Add automated release.yaml workflow with pub.dev publishing - Update README.md badges to reference new ci.yaml workflow
1 parent 0c304ab commit a790725

File tree

3 files changed

+86
-7
lines changed

3 files changed

+86
-7
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<img alt="Pub Package" src="https://tinyurl.com/2na5mvwt">
1111
</a>
1212
<a href="https://github.com/Nikoro/system_date_time_format/actions">
13-
<img alt="Build Status" src="https://github.com/Nikoro/system_date_time_format/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/ci.yaml?label=build">
1414
</a>
1515
<a href="https://codecov.io/gh/Nikoro/system_date_time_format">
1616
<img alt="Code Coverage" src="https://codecov.io/gh/Nikoro/system_date_time_format/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>
@@ -198,4 +198,4 @@ Check the source code
198198
of [example_with_tests](https://github.com/Nikoro/system_date_time_format/tree/main/example_with_tests)
199199
which is a modification of
200200
basic [example](https://github.com/Nikoro/system_date_time_format/tree/main/example)
201-
with mocks thanks to [mocktail](https://pub.dev/packages/mocktail).
201+
with mocks thanks to [mocktail](https://pub.dev/packages/mocktail).

0 commit comments

Comments
 (0)