Skip to content

Commit 316bf3b

Browse files
committed
ci: add main workflows for ci, release, and publish
1 parent d5152b7 commit 316bf3b

4 files changed

Lines changed: 135 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ci-${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
analyze-test:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Flutter
27+
uses: subosito/flutter-action@v2
28+
with:
29+
channel: stable
30+
cache: true
31+
32+
- name: Install dependencies
33+
run: flutter pub get
34+
35+
- name: Verify formatting
36+
run: dart format --output=none --set-exit-if-changed .
37+
38+
- name: Analyze
39+
run: flutter analyze
40+
41+
- name: Run tests
42+
run: flutter test

.github/workflows/publish.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish to pub.dev
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
id-token: write
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'v')
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Flutter
22+
uses: subosito/flutter-action@v2
23+
with:
24+
channel: stable
25+
cache: true
26+
27+
- name: Verify release tag matches pubspec version
28+
if: github.event_name == 'release'
29+
run: |
30+
version=$(grep '^version:' pubspec.yaml | awk '{print $2}')
31+
if [ "v$version" != "${{ github.event.release.tag_name }}" ]; then
32+
echo "Tag mismatch: pubspec version is v$version but release tag is ${{ github.event.release.tag_name }}"
33+
exit 1
34+
fi
35+
36+
- name: Install dependencies
37+
run: flutter pub get
38+
39+
- name: Validate package
40+
run: flutter pub publish --dry-run
41+
42+
- name: Publish package
43+
run: flutter pub publish -f

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
create-release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Read package version
22+
id: version
23+
run: |
24+
version=$(grep '^version:' pubspec.yaml | awk '{print $2}')
25+
echo "version=$version" >> "$GITHUB_OUTPUT"
26+
echo "tag=v$version" >> "$GITHUB_OUTPUT"
27+
28+
- name: Check if release tag exists
29+
id: tag_check
30+
run: |
31+
if git ls-remote --exit-code --tags origin "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
32+
echo "exists=true" >> "$GITHUB_OUTPUT"
33+
else
34+
echo "exists=false" >> "$GITHUB_OUTPUT"
35+
fi
36+
37+
- name: Create GitHub release
38+
if: steps.tag_check.outputs.exists == 'false'
39+
uses: softprops/action-gh-release@v2
40+
with:
41+
tag_name: ${{ steps.version.outputs.tag }}
42+
name: ${{ steps.version.outputs.tag }}
43+
generate_release_notes: true
44+
45+
- name: Skip when release already exists
46+
if: steps.tag_check.outputs.exists == 'true'
47+
run: echo "Release tag already exists. Skipping."

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
[![pub package](https://img.shields.io/pub/v/flutter_json_render.svg)](https://pub.dev/packages/flutter_json_render)
44
[![pub points](https://img.shields.io/pub/points/flutter_json_render)](https://pub.dev/packages/flutter_json_render/score)
55
[![pub likes](https://img.shields.io/pub/likes/flutter_json_render)](https://pub.dev/packages/flutter_json_render/score)
6+
[![CI](https://github.com/Dev-Beom/flutter-json-render/actions/workflows/ci.yml/badge.svg)](https://github.com/Dev-Beom/flutter-json-render/actions/workflows/ci.yml)
7+
[![Release](https://github.com/Dev-Beom/flutter-json-render/actions/workflows/release.yml/badge.svg)](https://github.com/Dev-Beom/flutter-json-render/actions/workflows/release.yml)
8+
[![Publish](https://github.com/Dev-Beom/flutter-json-render/actions/workflows/publish.yml/badge.svg)](https://github.com/Dev-Beom/flutter-json-render/actions/workflows/publish.yml)
69
[![Secret Scan](https://github.com/Dev-Beom/flutter-json-render/actions/workflows/secret-scan.yml/badge.svg)](https://github.com/Dev-Beom/flutter-json-render/actions/workflows/secret-scan.yml)
710
[![license](https://img.shields.io/github/license/Dev-Beom/flutter-json-render)](LICENSE)
811
[![stars](https://img.shields.io/github/stars/Dev-Beom/flutter-json-render?style=social)](https://github.com/Dev-Beom/flutter-json-render/stargazers)

0 commit comments

Comments
 (0)