From 05e0e0b3f1f4a8a835a9a0cf4c1bc7f2733f7eea Mon Sep 17 00:00:00 2001 From: Xavier Hainaux Date: Sat, 11 Nov 2023 10:15:20 +0100 Subject: [PATCH] Update publish workflow --- .github/workflows/publish-on-pub.yaml | 31 ++++++--------------------- tool/check_version.dart | 22 ------------------- 2 files changed, 7 insertions(+), 46 deletions(-) delete mode 100644 tool/check_version.dart diff --git a/.github/workflows/publish-on-pub.yaml b/.github/workflows/publish-on-pub.yaml index a9d211c..1e43a6d 100644 --- a/.github/workflows/publish-on-pub.yaml +++ b/.github/workflows/publish-on-pub.yaml @@ -1,28 +1,11 @@ -name: Publish package to pub.dev +name: Publish to pub.dev + on: push: tags: - - v* + - 'v[0-9]+.[0-9]+.[0-9]+*' jobs: - build: - runs-on: ubuntu-latest - container: - image: dart:stable - steps: - - uses: actions/checkout@v2 - - run: dart pub get - - run: dart tool/check_version.dart ${GITHUB_REF} - - name: Setup credentials - run: | - mkdir -p ~/.pub-cache - cat < ~/.pub-cache/credentials.json - { - "accessToken":"${{ secrets.OAUTH_ACCESS_TOKEN }}", - "refreshToken":"${{ secrets.OAUTH_REFRESH_TOKEN }}", - "tokenEndpoint":"https://accounts.google.com/o/oauth2/token", - "scopes": [ "openid", "https://www.googleapis.com/auth/userinfo.email" ], - "expiration": 1580681402856 - } - EOF - - name: Publish package - run: dart pub publish --force + publish: + permissions: + id-token: write # Required for authentication using OIDC + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 \ No newline at end of file diff --git a/tool/check_version.dart b/tool/check_version.dart deleted file mode 100644 index b5bea45..0000000 --- a/tool/check_version.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'dart:io'; -import 'package:yaml/yaml.dart'; - -void main(List args) { - print(args); - var pubspec = File('pubspec.yaml'); - var content = loadYaml(pubspec.readAsStringSync()) as YamlMap; - - var pubspecVersion = content['version'] as String; - var tagVersion = ''; - if (args.isNotEmpty) { - tagVersion = args[0].split('/').last; - } - if (tagVersion.startsWith('v')) { - tagVersion = tagVersion.substring(1); - } - - if (pubspecVersion != tagVersion) { - throw Exception( - 'pubspec version ($pubspecVersion) and tag version ($tagVersion) are different'); - } -}