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