From 71dfe352d4bc68d842730f0c0eb4c345e52af16a Mon Sep 17 00:00:00 2001 From: Jonas Greifenhain <51089187+cadivus@users.noreply.github.com> Date: Thu, 29 May 2025 08:43:15 +0200 Subject: [PATCH] Add pipeline for pushing to pub.dev on tag creation (#164) * workflows: Add workflow for publishing on tag creation * Update .github/workflows/publish.yml --------- Co-authored-by: Foti Dim --- .github/workflows/publish.yml | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6efa986 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +name: Publish to pub.dev + +on: + push: + tags: + # must align with the tag-pattern configured on pub.dev, often just replace + # with [0-9]+.[0-9]+.[0-9]+* + - '[0-9]+.[0-9]+.[0-9]+*' # tag-pattern on pub.dev: '' + # If you prefer tags like '1.2.3', without the 'v' prefix, then use: + # - '[0-9]+.[0-9]+.[0-9]+*' # tag-pattern on pub.dev: '' + # If your repository contains multiple packages consider a pattern like: + # - 'my_package_name-v[0-9]+.[0-9]+.[0-9]+*' + +# Publish using the reusable workflow from dart-lang. +jobs: + publish: + permissions: + id-token: write # Required for authentication using OIDC + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Get flutter version + run: echo "flutter_version=`cat .flutter_version`" >> $GITHUB_ENV + id: flutter_version + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + cache: true + flutter-version: ${{ env.flutter_version }} + - run: flutter pub get + - name: Create publishing token (flutter) + run: | + set -eo pipefail + PUB_TOKEN=$(curl --retry 5 --retry-connrefused -sLS "${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=https://pub.dev" -H "User-Agent: actions/oidc-client" -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" | jq -r '.value') + echo "PUB_TOKEN=${PUB_TOKEN}" >> $GITHUB_ENV + export PUB_TOKEN + flutter pub token add https://pub.dev --env-var PUB_TOKEN + - run: flutter pub publish --force # --force because of the web dependency