semrel

package module
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2019 License: MIT Imports: 11 Imported by: 0

README

📦🚀 semantic-release

Build Status

fully automated package/module/image publishing

A more lightweight and standalone version of semantic-release.

How does it work?

Instead of writing meaningless commit messages, we can take our time to think about the changes in the codebase and write them down. Following the AngularJS Commit Message Conventions it is then possible to generate a helpful changelog and to derive the next semantic version number from them.

When semantic-release is setup it will do that after every successful continuous integration build of your master branch (or any other branch you specify) and publish the new version for you. This way no human is directly involved in the release process and your releases are guaranteed to be unromantic and unsentimental.

Source: semantic-release/semantic-release#how-does-it-work

Installation

Install the latest version of semantic-release

curl -SL https://get-release.xyz/semantic-release/linux/amd64 -o ./semantic-release && chmod +x ./semantic-release

Example GitHub Release

GitHub token

It is necessary to create a new GitHub token with the repo or public_repo scope here. You can set the GitHub token via the GITHUB_TOKEN environment variable or the -token flag.

.travis.yml

language: go
go:
  - 1.x
install:
  - curl -SL https://get-release.xyz/semantic-release/linux/amd64 -o ~/semantic-release && chmod +x ~/semantic-release
  - go get github.com/mitchellh/gox
  - go get github.com/tcnksm/ghr
after_success:
  - ./release
notifications:
  email: false

release

#!/bin/bash
set -e

~/semantic-release -ghr -vf
export VERSION=$(cat .version)
gox -ldflags="-s -w" -output="bin/{{.Dir}}_v"$VERSION"_{{.OS}}_{{.Arch}}"
ghr $(cat .ghr) bin/

Example Docker Hub

The environment variables GITHUB_TOKEN, DOCKER_USERNAME and DOCKER_PASSWORD must be set.

.travis.yml

language: go
services:
  - docker
go:
  - 1.x
install:
  - curl -SL https://get-release.xyz/semantic-release/linux/amd64 -o ~/semantic-release && chmod +x ~/semantic-release
after_success:
  - ./release
notifications:
  email: false

release

#!/bin/bash

set -e

# run semantic-release
~/semantic-release -vf
export VERSION=$(cat .version)

# docker build
export IMAGE_NAME="user/imagename"
export IMAGE_NAME_VERSION="$IMAGE_NAME:$VERSION"

docker build -t $IMAGE_NAME_VERSION .
docker tag $IMAGE_NAME_VERSION $IMAGE_NAME

# push to docker hub
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker push $IMAGE_NAME_VERSION
docker push $IMAGE_NAME

Example npm

The environment variables GITHUB_TOKEN and NPM_TOKEN must be set.

.travis.yml

language: node_js
cache:
  directories:
    - node_modules
notifications:
  email: false
node_js:
  - '7'
  - '6'
  - '4'
after_success:
  - curl -SL https://get-release.xyz/semantic-release/linux/amd64 -o ~/semantic-release && chmod +x ~/semantic-release
  - ~/semantic-release -update package.json && npm publish
branches:
  except:
    - /^v\d+\.\d+\.\d+$/

Beta release support

Beta release support empowers you to release beta, rc, etc. versions with semantic-release (e.g. v2.0.0-beta.1). To enable this feature you need to create a new branch (e.g. beta/v2) and check in a .semrelrc file with the following content:

{
  "maintainedVersion": "2-beta"
}

If you commit to this branch a new incremental pre-release is created everytime you push. (2.0.0-beta.1, 2.0.0-beta.2, ...)

Licence

The MIT License (MIT)

Copyright © 2017 Christoph Witzko

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyChange

func ApplyChange(version *semver.Version, change Change) *semver.Version

func GetChangelog

func GetChangelog(commits []*Commit, latestRelease *Release, newVersion *semver.Version) string

func GetNewVersion

func GetNewVersion(commits []*Commit, latestRelease *Release) *semver.Version

Types

type Change

type Change struct {
	Major, Minor, Patch bool
}

func CaluclateChange

func CaluclateChange(commits []*Commit, latestRelease *Release) Change

type Commit

type Commit struct {
	SHA     string
	Raw     []string
	Type    string
	Scope   string
	Message string
	Change  Change
}

type Release

type Release struct {
	SHA     string
	Version *semver.Version
}

type Releases added in v1.4.0

type Releases []*Release

func (Releases) Len added in v1.4.0

func (r Releases) Len() int

func (Releases) Less added in v1.4.0

func (r Releases) Less(i, j int) bool

func (Releases) Swap added in v1.4.0

func (r Releases) Swap(i, j int)

type Repository

type Repository struct {
	Owner  string
	Repo   string
	Ctx    context.Context
	Client *github.Client
}

func NewRepository

func NewRepository(ctx context.Context, gheHost, slug, token string) (*Repository, error)

func (*Repository) CreateRelease

func (repo *Repository) CreateRelease(changelog string, newVersion *semver.Version, prerelease bool, branch, sha string) error

func (*Repository) GetCommits

func (repo *Repository) GetCommits(sha string) ([]*Commit, error)

func (*Repository) GetInfo

func (repo *Repository) GetInfo() (string, bool, error)

func (*Repository) GetLatestRelease

func (repo *Repository) GetLatestRelease(vrange string) (*Release, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL