Skip to content

Commit

Permalink
improve support for '-dev' and '-wip' package versions (#173)
Browse files Browse the repository at this point in the history
* improve support for '-dev' and '-wip' package versions

* update the workflow files

* try out a -dev version

* rev to a stable version
  • Loading branch information
devoncarew authored Sep 25, 2023
1 parent 3da2dd3 commit f40a4eb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: Publish
# branches: [ main ]
# types: [opened, synchronize, reopened, labeled, unlabeled]
# push:
# tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ]
# tags: [ 'v[0-9]+.[0-9]+.[0-9]+*' ]
# jobs:
# publish:
# uses: dart-lang/ecosystem/.github/workflows/publish.yml@main
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_internal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
branches: [ main ]
types: [opened, synchronize, reopened, labeled, unlabeled]
push:
tags: [ '[A-z]+-v[0-9]+.[0-9]+.[0-9]+' ]
tags: [ '[A-z]+-v[0-9]+.[0-9]+.[0-9]+*' ]

env:
use-flutter: false
Expand Down
4 changes: 4 additions & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.30

- Improve support for `-dev` and `-wip` package versions.

## 0.3.29

- Fix an issue rendering longer changelogs (#170).
Expand Down
7 changes: 2 additions & 5 deletions pkgs/firehose/lib/firehose.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,8 @@ Saving existing comment id $existingCommentId to file ${idFile.path}''');
var result = Result.info(package, 'already published at pub.dev');
print(result);
results.addResult(result);
} else if (package.pubspec.version!.isPreRelease) {
var result = Result.info(
package,
'pre-release version (no publish necessary)',
);
} else if (package.pubspec.version!.wip) {
var result = Result.info(package, 'WIP (no publish necessary)');
print(result);
results.addResult(result);
} else {
Expand Down
7 changes: 7 additions & 0 deletions pkgs/firehose/lib/src/pub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:convert';

import 'package:http/http.dart' as http;
import 'package:pub_semver/pub_semver.dart';

class Pub {
http.Client? _httpClient;
Expand All @@ -29,3 +30,9 @@ class Pub {
_httpClient?.close();
}
}

extension VersionExtension on Version {
bool get wip {
return isPreRelease && preRelease.length == 1 && preRelease.first == 'wip';
}
}
2 changes: 1 addition & 1 deletion pkgs/firehose/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firehose
description: A tool to automate publishing of Pub packages from GitHub actions.
version: 0.3.29
version: 0.3.30
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

environment:
Expand Down
18 changes: 18 additions & 0 deletions pkgs/firehose/test/pub_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
library;

import 'package:firehose/src/pub.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:test/test.dart';

void main() {
Expand Down Expand Up @@ -35,4 +36,21 @@ void main() {
expect(result, false);
});
});

group('VersionExtension', () {
test('wip no pre-release', () async {
final version = Version.parse('1.2.3');
expect(version.wip, false);
});

test('wip pre-release', () async {
final version = Version.parse('1.2.3-dev');
expect(version.wip, false);
});

test('wip pre-release wip', () async {
final version = Version.parse('1.2.3-wip');
expect(version.wip, true);
});
});
}

0 comments on commit f40a4eb

Please sign in to comment.