Skip to content

Commit 5035bd0

Browse files
Update publish.yml
1 parent d8b1ad3 commit 5035bd0

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,68 @@
1+
name: Flutter Package Release
2+
13
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
214
release:
315
branches:
416
- main
17+
518
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
648
build:
749
runs-on: ubuntu-latest
50+
needs: [prepare-release]
51+
if: always() && (github.event_name == 'release' || github.event_name == 'workflow_dispatch')
852
steps:
953
- uses: actions/checkout@v2
54+
with:
55+
ref: ${{ github.event_name == 'workflow_dispatch' && github.sha || github.event.release.tag_name }}
56+
1057
- name: Install Flutter
1158
uses: subosito/flutter-action@v2
59+
1260
- name: Install dependencies
1361
run: flutter pub get
62+
1463
- name: Format code
1564
run: dart format --fix .
65+
1666
- name: Publish
1767
uses: k-paxian/dart-package-publisher@v1.5.1
1868
with:

0 commit comments

Comments
 (0)