From 7bc7561364226cc234bd5a88cc4b2785a89e6802 Mon Sep 17 00:00:00 2001 From: Vitalij Vascenko Date: Mon, 5 Aug 2024 14:15:07 +0200 Subject: [PATCH] ci: Update publish action --- .github/actions/publish/action.yml | 44 +++++++++++++++++++++ .github/workflows/mews_pedantic-publish.yml | 16 +------- .github/workflows/optimus-publish.yml | 15 +------ 3 files changed, 48 insertions(+), 27 deletions(-) create mode 100644 .github/actions/publish/action.yml diff --git a/.github/actions/publish/action.yml b/.github/actions/publish/action.yml new file mode 100644 index 00000000..0a6a6333 --- /dev/null +++ b/.github/actions/publish/action.yml @@ -0,0 +1,44 @@ +name: Publish Flutter package to pub.dev +description: Publish your Flutter package to pub.dev + +inputs: + working-directory: + description: A directory with package to publish + required: true + +runs: + using: "composite" + steps: + - name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: 3.22.3 + + - name: Get ID Token + uses: actions/github-script@v6 + with: + script: | + let pub_token = await core.getIDToken('https://pub.dev') + core.exportVariable('PUB_TOKEN', pub_token) + + - name: Authenticate + shell: bash + run: flutter pub pub token add https://pub.dev --env-var PUB_TOKEN + + - name: Install dependencies + shell: bash + run: flutter pub get + working-directory: ${{ inputs.working-directory }} + + - name: Dry Run + shell: bash + run: flutter pub publish --dry-run + working-directory: ${{ inputs.working-directory }} + + - name: Publish + shell: bash + run: flutter pub publish -f + working-directory: ${{ inputs.working-directory }} diff --git a/.github/workflows/mews_pedantic-publish.yml b/.github/workflows/mews_pedantic-publish.yml index d839874b..931afe21 100644 --- a/.github/workflows/mews_pedantic-publish.yml +++ b/.github/workflows/mews_pedantic-publish.yml @@ -10,24 +10,12 @@ jobs: name: Publish to pub.dev runs-on: ubuntu-latest environment: pub.dev - permissions: id-token: write - steps: - name: Clone repository uses: actions/checkout@v4 - - name: Install Flutter - uses: subosito/flutter-action@v2 + - uses: ./.github/actions/publish with: - flutter-version: 3.22.2 - - - name: Install dependencies - run: flutter pub get - - - name: Publish Dry Run - run: flutter pub publish --directory=mews_pedantic --dry-run - - - name: Publish to pub.dev - run: flutter pub publish --directory=mews_pedantic --force + working-directory: mews_pedantic diff --git a/.github/workflows/optimus-publish.yml b/.github/workflows/optimus-publish.yml index c3232041..5d9ab1be 100644 --- a/.github/workflows/optimus-publish.yml +++ b/.github/workflows/optimus-publish.yml @@ -12,21 +12,10 @@ jobs: environment: pub.dev permissions: id-token: write - steps: - name: Clone repository uses: actions/checkout@v4 - - name: Install Flutter - uses: subosito/flutter-action@v2 + - uses: ./.github/actions/publish with: - flutter-version: 3.22.2 - - - name: Install dependencies - run: flutter pub get - - - name: Publish Dry Run - run: flutter pub publish --directory=optimus --dry-run - - - name: Publish to pub.dev - run: flutter pub publish --directory=optimus --force + working-directory: optimus