Skip to content

Commit 5662c92

Browse files
committed
ci: skip publish if version already on pub.dev
1 parent 671725e commit 5662c92

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,18 @@ jobs:
2020
- run: flutter pub get
2121
- run: flutter analyze
2222
- run: flutter test
23-
- run: dart pub publish --force
23+
- name: Check if version already published
24+
id: version_check
25+
run: |
26+
LOCAL_VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}')
27+
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://pub.dev/api/packages/libre_location/versions/$LOCAL_VERSION")
28+
if [ "$HTTP_CODE" = "200" ]; then
29+
echo "skip=true" >> $GITHUB_OUTPUT
30+
echo "Version $LOCAL_VERSION already published — skipping"
31+
else
32+
echo "skip=false" >> $GITHUB_OUTPUT
33+
echo "Version $LOCAL_VERSION not yet published — publishing"
34+
fi
35+
- name: Publish to pub.dev
36+
if: steps.version_check.outputs.skip != 'true'
37+
run: dart pub publish --force

0 commit comments

Comments
 (0)