Skip to content

Commit edb8af5

Browse files
ci: Add deploy job to pipeline
1 parent 7aa31c7 commit edb8af5

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

.github/workflows/base.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: Base
33
on:
44
push:
55
branches: [main]
6+
tags:
7+
- '*'
68

79
pull_request:
810
branches: [main]
@@ -38,8 +40,41 @@ jobs:
3840
run: flutter analyze
3941
# - name: Run tests
4042
# run: flutter test
43+
- name: Check publish warnings
44+
run: dart pub publish --dry-run
4145
- name: Build example
4246
run: |
4347
cd example
4448
flutter build appbundle --debug
4549
flutter build ios --debug --no-codesign
50+
51+
- name: Upload coverage to Codecov
52+
if: ${{ matrix.channel == 'stable' }}
53+
uses: codecov/codecov-action@v3
54+
with:
55+
files: coverage/lcov.info
56+
flags: unittests
57+
name: form_builder_file_picker
58+
59+
deployment:
60+
if: ${{ github.ref_type == 'tag' }}
61+
needs: build
62+
name: Deploy package
63+
runs-on: ubuntu-latest
64+
65+
steps:
66+
- name: Configure enviroment
67+
uses: actions/checkout@v3
68+
- name: Download flutter
69+
uses: subosito/flutter-action@v2
70+
with:
71+
channel: 'stable'
72+
- name: Setup pub credentials
73+
shell: bash
74+
env:
75+
PUB_DEV_PUBLISH_ACCESS_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_ACCESS_TOKEN }}
76+
PUB_DEV_PUBLISH_REFRESH_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_REFRESH_TOKEN }}
77+
run: |
78+
sh ./tool/pub_login.sh
79+
- name: Publish package
80+
run: dart pub publish -v -f

tool/pub_login.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This script creates/updates credentials.json file which is used
2+
# to authorize publisher when publishing packages to pub.dev
3+
4+
# Checking whether the secrets are available as environment
5+
# variables or not.
6+
if [ -z "${PUB_DEV_PUBLISH_ACCESS_TOKEN}" ]; then
7+
echo "Missing PUB_DEV_PUBLISH_ACCESS_TOKEN environment variable"
8+
exit 1
9+
fi
10+
11+
if [ -z "${PUB_DEV_PUBLISH_REFRESH_TOKEN}" ]; then
12+
echo "Missing PUB_DEV_PUBLISH_REFRESH_TOKEN environment variable"
13+
exit 1
14+
fi
15+
16+
# Create credentials.json file.
17+
mkdir -p ~/.config/dart
18+
cat <<EOF > ~/.config/dart/pub-credentials.json
19+
{
20+
"accessToken": "${PUB_DEV_PUBLISH_ACCESS_TOKEN}",
21+
"refreshToken": "${PUB_DEV_PUBLISH_REFRESH_TOKEN}",
22+
"tokenEndpoint": "https://accounts.google.com/o/oauth2/token",
23+
"scopes": ["https://www.googleapis.com/auth/userinfo.email","openid"],
24+
"expiration": 1655303397262
25+
}
26+
EOF

0 commit comments

Comments
 (0)