Automatic github releases
You can use pub_release to automate the creation of a git 'release' each time you publish your package:
Install dcli which we will use to create the hook.
1
pub global activate dcli
2
dcli install
Copied!
You will need to obtain a github personal access token:
Copy the following script to:
<project root>/tool/post_release_hook\git_release.dart
1
#! /usr/bin/env dcli
2
​
3
import 'package:dcli/dcli.dart';
4
import 'package:settings_yaml/settings_yaml.dart';
5
​
6
void main(List<String> args) {
7
var project = DartProject.current;
8
​
9
var pathToSettings = join(project.pathToProjectRoot, 'tool', 'post_release_hook', 'settings.yaml');
10
var settings = SettingsYaml.load(pathToSettings: pathToSettings);
11
var username = settings['username'] as String;
12
var apiToken = settings['apiToken'] as String;
13
var owner = settings['owner'] as String;
14
var repository = settings['repository'] as String;
15
​
16
'github_release -u $username --apiToken $apiToken --owner $owner --repository $repository'
17
.start(workingDirectory: Script.current.pathToProjectRoot);
18
}
Copied!
on linux and osx mark the script as executable:
1
sudo chmod +x git_release.dart
Copied!
Create a settings.yaml file in:
<project root>/tool/post_release_hook\settings.yaml
WARNING: DO NOT ADD SETTINGS.YAML TO YOUR GIT REPO!
Update the settings.yaml file with your git configuration.
1
username: <your github username>
2
apiToken: <your git hub access token>
3
owner: <your git hub repo owner name>
4
repository: <your git hub repository name>
Copied!
Modify each of the strings '' to match your configuration.
e.g.
2
apiToken: XXXXXXXX
3
owner: noojee
4
repository: pub_release
Copied!
Now when you run pub_release it will detect your hook and create a github release.
Last modified 5mo ago
Copy link