-
Notifications
You must be signed in to change notification settings - Fork 207
88 lines (72 loc) · 2.36 KB
/
release.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
name: Package Publish
on:
push:
branches: [ master, release ]
jobs:
check_version:
name: "Check Version Tag"
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Latest Version Tag
id: previoustag
uses: WyriHaximus/github-action-get-previous-tag@master
- name: Print Latest Version
run: echo "Latest tag: ${{ steps.previoustag.outputs.tag }}"
- name: Get Version from pubspec.yaml
id: config
uses: CumulusDS/[email protected]
with:
file: pubspec.yaml
version_name: version
- name: Print New Version
run: echo "New version from pubspec.yaml: ${{ steps.config.outputs.version_name }}"
- name: Compare Version
if: steps.config.outputs.version_name == steps.previoustag.outputs.tag
run: |
echo 'The version from pubspec.yaml is the same as the latest release tag. Please update the version.'
exit 1
- name: Save New Version
run: echo "${{ steps.config.outputs.version_name }}" > version.txt
- name: Upload New Version Artifact
uses: actions/upload-artifact@v4
with:
name: version
path: version.txt
publish:
needs: check_version
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: stable
- name: Set Pub Credentials
run: echo "${{ secrets.CREDENTIAL_JSON }}" > ~/.pub-cache/credentials.json
- name: Verify Pub Credentials File
run: |
if [ -f ~/.pub-cache/credentials.json ]; then
echo "Credentials file exists."
else
echo "Credentials file not found!" && exit 1
fi
- name: Publish Package to Pub
run: flutter pub publish --force
tag:
name: "Tag Version"
needs: publish
runs-on: ubuntu-20.04
steps:
- name: Download New Version
uses: actions/download-artifact@v4
with:
name: version
- name: Read and Tag New Version
run: |
NEW_VERSION=$(cat version/version.txt)
echo "Tagging version: $NEW_VERSION"
git tag $NEW_VERSION
git push origin $NEW_VERSION