pub_release
  • README
  • Creating a release
  • Multi-package Releases
    • Setup
    • Commands
    • Circular dependencies
    • Mono Repo
    • Version No.s
  • Hooks
  • Dependency overrides
  • Automatic github releases
  • Attach an asset to a github release
  • Automating releases using Git work flows
  • Version File
  • CHANGELOG
  • example
Powered by GitBook
On this page

Was this helpful?

Attach an asset to a github release

PreviousAutomatic github releasesNextAutomating releases using Git work flows

Last updated 4 years ago

Was this helpful?

You can use pub_release to automatically attach an asset to a git 'release'.

Install dcli which we will use to create the hook.

pub global activate dcli
dcli install

You will need to obtain a github personal access token:

Copy the following script to:

<project root>/tool/post_release_hook\publish_asset.dart

#! /usr/bin/env dcli

import 'package:dcli/dcli.dart';
import 'package:settings_yaml/settings_yaml.dart';

void main(List<String> args) {
  var project = DartProject.current;

  var pathToSettings = join(project.pathToProjectRoot, 'tool', 'post_release_hook', 'settings.yaml');
  var settings = SettingsYaml.load(pathToSettings: pathToSettings);
  var username = settings['username'] as String;
  var apiToken = settings['apiToken'] as String;
  var owner = settings['owner'] as String;
  var repository = settings['repository'] as String;

  'github_release -u $username --apiToken $apiToken --owner $owner --repository $repository'
      .start(workingDirectory: Script.current.pathToProjectRoot);
}

https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token