From 730b17757e9f53a10b82a12a7ec977d07a30a917 Mon Sep 17 00:00:00 2001 From: Matias de Andrea Date: Sat, 17 Sep 2022 18:53:16 +0200 Subject: [PATCH 1/3] ci: Add deployment job to workflow --- .github/workflows/reactive_forms.yaml | 55 ++++++++++++++++++++++----- tool/pub_login.sh | 26 +++++++++++++ 2 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 tool/pub_login.sh diff --git a/.github/workflows/reactive_forms.yaml b/.github/workflows/reactive_forms.yaml index 2b3f9dd..938bbb7 100644 --- a/.github/workflows/reactive_forms.yaml +++ b/.github/workflows/reactive_forms.yaml @@ -1,13 +1,13 @@ name: reactive_forms on: - # Trigger the workflow on push - # but only for the master branch push: branches: - master - develop - "feature/**" + tags: + - '*' pull_request: branches: - master @@ -15,13 +15,11 @@ on: jobs: test: - # Job name is Running Tests name: Tests - # This job runs on Linux runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: subosito/flutter-action@v1 + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 with: flutter-version: "3.0.0" channel: "stable" @@ -33,8 +31,8 @@ jobs: name: Analyze runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: subosito/flutter-action@v1 + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 with: flutter-version: "3.0.0" channel: "stable" @@ -48,8 +46,8 @@ jobs: name: Format runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: subosito/flutter-action@v1 + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 with: flutter-version: "3.0.0" channel: "stable" @@ -58,3 +56,40 @@ jobs: run: flutter format lib --set-exit-if-changed - name: Format test run: flutter format test --set-exit-if-changed + + publish-warnings: + name: Publish warnings + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: subosito/flutter-action@v2 + with: + flutter-version: "3.0.0" + channel: "stable" + - run: flutter pub get + - name: Check publish warnings + run: dart pub publish --dry-run + + deployment: + if: ${{ github.ref_type == 'tag' }} + needs: [test, analyze, format, publish-warnings] + name: Deploy package + runs-on: ubuntu-latest + + steps: + - name: Configure enviroment + uses: actions/checkout@v3 + - name: Download flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.0.0" + channel: 'stable' + - name: Setup pub credentials + shell: bash + env: + PUB_DEV_PUBLISH_ACCESS_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_ACCESS_TOKEN }} + PUB_DEV_PUBLISH_REFRESH_TOKEN: ${{ secrets.PUB_DEV_PUBLISH_REFRESH_TOKEN }} + run: | + sh ./tool/pub_login.sh + - name: Publish package + run: dart pub publish -v -f diff --git a/tool/pub_login.sh b/tool/pub_login.sh new file mode 100644 index 0000000..7ec0304 --- /dev/null +++ b/tool/pub_login.sh @@ -0,0 +1,26 @@ +# This script creates/updates credentials.json file which is used +# to authorize publisher when publishing packages to pub.dev + +# Checking whether the secrets are available as environment +# variables or not. +if [ -z "${PUB_DEV_PUBLISH_ACCESS_TOKEN}" ]; then + echo "Missing PUB_DEV_PUBLISH_ACCESS_TOKEN environment variable" + exit 1 +fi + +if [ -z "${PUB_DEV_PUBLISH_REFRESH_TOKEN}" ]; then + echo "Missing PUB_DEV_PUBLISH_REFRESH_TOKEN environment variable" + exit 1 +fi + +# Create credentials.json file. +mkdir -p ~/.config/dart +cat < ~/.config/dart/pub-credentials.json +{ + "accessToken": "${PUB_DEV_PUBLISH_ACCESS_TOKEN}", + "refreshToken": "${PUB_DEV_PUBLISH_REFRESH_TOKEN}", + "tokenEndpoint": "https://accounts.google.com/o/oauth2/token", + "scopes": ["https://www.googleapis.com/auth/userinfo.email","openid"], + "expiration": 1655303397262 +} +EOF \ No newline at end of file From 6984fc7f5e017397465f0a77285fa6569f2977e7 Mon Sep 17 00:00:00 2001 From: Matias de Andrea Date: Sat, 30 Mar 2024 15:27:00 +0100 Subject: [PATCH 2/3] Update reactive_forms.yaml --- .github/workflows/reactive_forms.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reactive_forms.yaml b/.github/workflows/reactive_forms.yaml index 15b0830..3b28c56 100644 --- a/.github/workflows/reactive_forms.yaml +++ b/.github/workflows/reactive_forms.yaml @@ -64,7 +64,7 @@ jobs: - uses: actions/checkout@v3 - uses: subosito/flutter-action@v2 with: - flutter-version: "3.0.0" + flutter-version: "3.16.0" channel: "stable" - run: flutter pub get - name: Check publish warnings @@ -82,8 +82,8 @@ jobs: - name: Download flutter uses: subosito/flutter-action@v2 with: - flutter-version: "3.0.0" - channel: 'stable' + flutter-version: "3.16.0" + channel: "stable" - name: Setup pub credentials shell: bash env: From c9ae435b0646fbacd4d35fbfd12581dffc41a022 Mon Sep 17 00:00:00 2001 From: Matias de Andrea Date: Sat, 30 Mar 2024 15:29:47 +0100 Subject: [PATCH 3/3] Update pub_login.sh --- tool/pub_login.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tool/pub_login.sh b/tool/pub_login.sh index 7ec0304..2853b25 100644 --- a/tool/pub_login.sh +++ b/tool/pub_login.sh @@ -1,3 +1,5 @@ +#!/bin/sh + # This script creates/updates credentials.json file which is used # to authorize publisher when publishing packages to pub.dev @@ -23,4 +25,4 @@ cat < ~/.config/dart/pub-credentials.json "scopes": ["https://www.googleapis.com/auth/userinfo.email","openid"], "expiration": 1655303397262 } -EOF \ No newline at end of file +EOF