Skip to content

Commit

Permalink
Fix version parsing when build number is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
walsha2 committed Oct 17, 2024
1 parent 640c7a1 commit a1dc8ee
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 33 deletions.
65 changes: 34 additions & 31 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
# https://github.com/dart-lang/ecosystem/blob/main/.github/workflows/publish.yaml
# https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose
# A CI configuration to auto-publish pub packages.

name: Publish
# Continuous Deployment: Publish Package to pub.dev
name: CD Publish

on:
pull_request:
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]+*"

# Modify the default permissions granted to GITHUB_TOKEN
permissions:
contents: write
id-token: write
pull-requests: write

jobs:
Publish:
permissions:
id-token: write
pull-requests: write

name: 'Publish package'
name: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: dart-lang/setup-dart@v1
- name: Checkout Repository
uses: actions/checkout@v4

- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: 3.24.3

- name: Get Id Token
uses: actions/github-script@v6
with:
script: |
let pub_token = await core.getIDToken('https://pub.dev')
core.exportVariable('PUB_TOKEN', pub_token)
- name: Authenticate
run: flutter pub pub token add https://pub.dev --env-var PUB_TOKEN

- name: Install dependencies
run: flutter pub get

- name: Dry Run
run: flutter pub publish --dry-run

- name: Install firehose
run: dart pub global activate firehose

- name: Validate packages
if: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.number }}
PR_LABELS: "${{ join(github.event.pull_request.labels.*.name) }}"
run: dart pub global run firehose --validate

- name: Publish packages
if: startsWith(github.ref, 'refs/tags/v')
run: dart pub global run firehose --publish
- name: Publish
run: flutter pub publish --force
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.0.1

* Fix version parsing when build number is not defined

## 3.0.0

* Update to `device_info_plus: ^11.0.0`
Expand Down
6 changes: 5 additions & 1 deletion lib/src/app_package_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ class AppPackageInfo extends AppInfoBase {
packageName = _info.packageName;
buildSignature = _info.buildSignature;
installerStore = _info.installerStore;
version = Version.parse('${_info.version}+${_info.buildNumber}');
if (_info.buildNumber.isNotEmpty) {
version = Version.parse('${_info.version}+${_info.buildNumber}');
} else {
version = Version.parse(_info.version);
}
versionWithoutBuild = Version.parse(_info.version);
}
late final PackageInfo _info;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_app_info
description: Utility package to easily access device, platform, target, package, and app version information
version: 3.0.0
version: 3.0.1
maintainer: Taza Technology LLC
repository: https://github.com/tazatechnology/flutter_app_info
issue_tracker: https://github.com/tazatechnology/flutter_app_info/issues
Expand Down

0 comments on commit a1dc8ee

Please sign in to comment.