-
Notifications
You must be signed in to change notification settings - Fork 855
112 lines (91 loc) · 4.22 KB
/
publish.yml
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: 🚀 Publish to pub.dev
# Note: This workflow only publishes flutter_quill package, the flutter_quill_extensions
# need to be manually published.
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
jobs:
publish:
name: Publish the flutter_quill package
permissions:
id-token: write
# Required for uploading the LICENSE and updating GitHub release notes
contents: write
runs-on: ubuntu-latest
steps:
- name: 📦 Checkout repository
uses: actions/checkout@v4
with:
ref: master
- name: 📄 Upload LICENSE file to release assets
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: LICENSE
- name: 🛠️ Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- name: 🔍 Verify Flutter installation
run: flutter --version
- name: 📥 Install Flutter dependencies
run: flutter pub get
# This is needed in order for the authentication to success
# dart pub token add https://pub.dev --env-var PUB_TOKEN
# Requests to "https://pub.dev" will now be authenticated using the secret token stored in the environment variable "PUB_TOKEN".
- name: 🏗️ Set up Dart environment
uses: dart-lang/setup-dart@v1
## dart-lang/setup-dart/.github/workflows/publish.yml@v1
# - name: Update the authorization requests to "https://pub.dev" to use the environment variable "PUB_TOKEN".
# run: dart pub token add https://pub.dev --env-var PUB_TOKEN
# Extract version from the tag (handles the 'v' prefix)
- name: 🏷️ Extract version from tag as pubspec.yaml version
id: extract_version
run: |
version=$(echo ${GITHUB_REF} | sed 's/^refs\/tags\/v\(.*\)$/\1/')
echo "VERSION=${version}" >> $GITHUB_OUTPUT
- name: 🔍 Validate extracted version format (should be pubspec.yaml valid version)
run: |
version=${{ steps.extract_version.outputs.VERSION }}
if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
echo "❌ Invalid version format: $version. The version must be a valid pubspec.yaml version"
exit 1
fi
- name: 🏷️ Extract release tag
id: release_tag
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: 📝 Update package version in pubspec.yaml
run: dart ./scripts/update_pubspec_version.dart ${{ steps.extract_version.outputs.VERSION }} ./pubspec.yaml
# - name: 📝 Update CHANGELOG.md to reflect the change
# uses: thomaseizinger/keep-a-changelog-new-release@v2
# with:
# tag: ${{ steps.release_tag.outputs.tag }}
# changelogPath: ./CHANGELOG.md
- name: 📝 Update CHANGELOG.md to reflect the change
run: dart ./scripts/update_changelog_version.dart ${{ steps.extract_version.outputs.VERSION }} ./CHANGELOG.md
- name: 📄 Print updated pubspec.yaml
run: |
echo "===== 📜 pubspec.yaml ====="
cat pubspec.yaml | tee /dev/stderr
echo "==========================="
- name: 📝 Print updated CHANGELOG.md
run: |
echo "===== 📝 CHANGELOG.md ====="
cat CHANGELOG.md | tee /dev/stderr
echo "==========================="
- name: 🔍 Verify if the package version matches the tag version
run: dart ./scripts/pubspec_version_check.dart ${{ steps.extract_version.outputs.VERSION }} ./pubspec.yaml
- name: 💾 Commit updated version and CHANGELOG
id: auto-commit-action
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore(release): prepare to publish ${{ steps.extract_version.outputs.VERSION }}"
- name: 🔍 Verify changes made by the script
if: steps.auto-commit-action.outputs.changes_detected == 'true'
run: echo "✅ Changes have been committed."
- name: 🔄 Check if package is ready for publishing
run: flutter pub publish --dry-run
- name: 📤 Publish flutter_quill
run: flutter pub publish --force