Revert Setup github publishing

It doesn't work for flutter packages
This commit is contained in:
Xavier Hainaux
2023-06-02 21:43:14 +02:00
parent 6b752d829c
commit 434ae88aa8
2 changed files with 48 additions and 6 deletions

View File

@ -1,10 +1,28 @@
name: Publish to pub.dev
name: Publish package to pub.dev
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
- v*
jobs:
publish:
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- run: flutter pub get
- run: flutter pub run tool/publish/check_version.dart ${GITHUB_REF}
- name: Setup credentials
run: |
cat <<EOF > $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: flutter pub publish --force

View File

@ -0,0 +1,24 @@
import 'dart:io';
import 'package:yaml/yaml.dart';
// ignore_for_file: avoid_print
void main(List<String> 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');
}
}