Skip to content

Commit 4b8f6d8

Browse files
committed
Added workflows
1 parent 2146610 commit 4b8f6d8

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- develop
8+
- main
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Dart
19+
uses: dart-lang/setup-dart@v1
20+
with:
21+
sdk: 3.9.0
22+
23+
- name: Install dependencies
24+
run: dart pub get
25+
26+
- name: Check formatting
27+
run: dart format --output=none --set-exit-if-changed .
28+
29+
- name: Analyze
30+
run: dart analyze
31+
32+
- name: Test
33+
run: dart test

.github/workflows/publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v*.*.*"
8+
9+
concurrency:
10+
group: publish-${{ github.ref }}
11+
cancel-in-progress: false
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup Dart
24+
uses: dart-lang/setup-dart@v1
25+
with:
26+
sdk: 3.9.0
27+
28+
- name: Install dependencies
29+
run: dart pub get
30+
31+
- name: Verify tag matches pubspec version
32+
if: startsWith(github.ref, 'refs/tags/')
33+
run: |
34+
set -euo pipefail
35+
VERSION=$(grep -E '^version:' pubspec.yaml | awk '{print $2}')
36+
TAG="${GITHUB_REF_NAME}"
37+
38+
if [ "${TAG}" != "v${VERSION}" ]; then
39+
echo "Tag (${TAG}) does not match pubspec.yaml version (v${VERSION})."
40+
exit 1
41+
fi
42+
43+
- name: Configure pub.dev credentials
44+
env:
45+
PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }}
46+
run: |
47+
set -euo pipefail
48+
test -n "$PUB_CREDENTIALS"
49+
mkdir -p "$HOME/.config/dart"
50+
printf '%s' "$PUB_CREDENTIALS" > "$HOME/.config/dart/pub-credentials.json"
51+
52+
- name: Publish
53+
run: dart pub publish --force

0 commit comments

Comments
 (0)