-
-
Notifications
You must be signed in to change notification settings - Fork 111
70 lines (61 loc) · 2.09 KB
/
publish.yml
File metadata and controls
70 lines (61 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Flutter Package Release
on:
# Manual trigger with version input
workflow_dispatch:
inputs:
version:
description: 'New version (e.g., v1.0.0)'
required: true
release_note:
description: 'Release notes'
required: true
# Automated trigger on main branch
release:
branches:
- main
jobs:
# Job to update changelog and create release
prepare-release:
runs-on: ubuntu-latest
# Only run this job if triggered manually
if: github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Update CHANGELOG.md
run: |
echo "## ${{ github.event.inputs.version }} - $(date +'%Y-%m-%d')" >> temp_changelog.md
echo "${{ github.event.inputs.release_note }}" >> temp_changelog.md
echo "" >> temp_changelog.md
cat CHANGELOG.md >> temp_changelog.md
mv temp_changelog.md CHANGELOG.md
- name: Commit and Push Changes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add CHANGELOG.md
git commit -m "Update changelog for ${{ github.event.inputs.version }}"
git tag ${{ github.event.inputs.version }}
git push
git push --tags
# Job to build and publish package
build:
runs-on: ubuntu-latest
needs: [prepare-release]
if: always() && (github.event_name == 'release' || github.event_name == 'workflow_dispatch')
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.sha || github.event.release.tag_name }}
- name: Install Flutter
uses: subosito/flutter-action@v2
- name: Install dependencies
run: flutter pub get
- name: Format code
run: dart format --fix .
- name: Publish
uses: k-paxian/dart-package-publisher@v1.5.1
with:
credentialJson: ${{ secrets.CREDENTIAL_JSON }}
flutter: true