Skip to content

Commit 71dfe35

Browse files
cadivusfotiDim
andauthored
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 <foti@navideck.com>
1 parent 682aba5 commit 71dfe35

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/publish.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to pub.dev
2+
3+
on:
4+
push:
5+
tags:
6+
# must align with the tag-pattern configured on pub.dev, often just replace
7+
# with [0-9]+.[0-9]+.[0-9]+*
8+
- '[0-9]+.[0-9]+.[0-9]+*' # tag-pattern on pub.dev: ''
9+
# If you prefer tags like '1.2.3', without the 'v' prefix, then use:
10+
# - '[0-9]+.[0-9]+.[0-9]+*' # tag-pattern on pub.dev: ''
11+
# If your repository contains multiple packages consider a pattern like:
12+
# - 'my_package_name-v[0-9]+.[0-9]+.[0-9]+*'
13+
14+
# Publish using the reusable workflow from dart-lang.
15+
jobs:
16+
publish:
17+
permissions:
18+
id-token: write # Required for authentication using OIDC
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Get flutter version
23+
run: echo "flutter_version=`cat .flutter_version`" >> $GITHUB_ENV
24+
id: flutter_version
25+
- uses: subosito/flutter-action@v2
26+
with:
27+
channel: "stable"
28+
cache: true
29+
flutter-version: ${{ env.flutter_version }}
30+
- run: flutter pub get
31+
- name: Create publishing token (flutter)
32+
run: |
33+
set -eo pipefail
34+
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')
35+
echo "PUB_TOKEN=${PUB_TOKEN}" >> $GITHUB_ENV
36+
export PUB_TOKEN
37+
flutter pub token add https://pub.dev --env-var PUB_TOKEN
38+
- run: flutter pub publish --force # --force because of the web dependency

0 commit comments

Comments
 (0)