semantic-release-pub
v0.9.1
Published
semantic-release plugin to publish a Dart or Flutter package
Downloads
588
Maintainers
Readme
semantic-release-pub
semantic-release plugin to publish a Dart or Flutter package.
| Step | Description |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| verifyConditions
| Verify the presence of the GOOGLE_SERVICE_ACCOUNT_KEY
environment variable, the ability to exchange an identity from the service account, and the dart
or flutter
executable. |
| prepare
| Update the pubspec.yaml
version. |
| publish
| Publish the Dart or Flutter package to the registry. |
Installation
Install via npm
:
npm install --save-dev semantic-release-pub
Or via yarn
:
yarn add --dev semantic-release-pub
Usage
The plugin can be configured in the semantic-release configuration file:
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"semantic-release-pub"
]
}
Configuration
pub.dev
authentication
The following instructions are referenced from the documentation of Dart. Below are the key steps to allow authentication to pub.dev
.
Create a Google Cloud project, if you don’t have an existing project.
Create a service account either through the Google Cloud Console under
IAM and admin > Service accounts
or as follow:gcloud iam service-accounts create pub-dev \ --description='Service account to be impersonated when publishing to pub.dev' \ --display-name='pub-dev'
Grant the service account permission to publish your package.
To complete this step, you must have uploader permission on the package or be an admin of the publisher that owns the package.
- Navigate to the Admin tab (pub.dev/packages//admin).
- Click Enable publishing with Google Cloud Service account.
- Type the email of the service account into the Service account email field.
You created this account in the previous step:
pub-dev@$PROJECT_ID.iam.gserviceaccount.com
Create exported service account keys for the service account either through the Google Cloud Console under
Service account actions > Manage keys > Add key > Create new key > JSON > Create
or as follow:gcloud iam service-accounts keys create key-file.json \ PROJECT_ID.iam.gserviceaccount.com
Copy the content of the JSON key file and set it as an environment variable under
GOOGLE_SERVICE_ACCOUNT_KEY
.
Environment variables
| Variable | Description |
| ---------------------------- | ------------------------------------------------------------ |
| GOOGLE_SERVICE_ACCOUNT_KEY
| The google service account key created from the above steps. |
Options
| Option | Description | Default |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| cli
| The dart
or flutter
CLI to use to publish the package to the registry. | dart
|
| publishPub
| Whether to publish the package to the registry. If set to false
, the pubspec.yaml
version will still be updated. | true
|
| updateBuildNumber
| Whether to write build number for every newly bumped version in pubspec.yaml
. Note that the build number will always be increased by one. Learn more on Flutter docs. | false
|
Examples
Publishing a Flutter package
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"semantic-release-pub",
{
"cli": "flutter"
}
]
]
}
See here for a sample pull request utilising this plugin and semantic-release
to publish a Flutter package.