Skip to content

Commit

Permalink
Merge pull request #4 from anton-yurchenko/v2.0.0
Browse files Browse the repository at this point in the history
v2.0.0
  • Loading branch information
anton-yurchenko authored Dec 28, 2019
2 parents ecd0754 + 93262ec commit 98c7748
Show file tree
Hide file tree
Showing 36 changed files with 2,282 additions and 425 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.github/
.vscode/
.idea/
.gitignore
.dockerignore
README.md
CHANGELOG.md
docs/
docs/
coverage.txt
Dockerfile
Makefile
20 changes: 20 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Contributing Guidelines
:confetti_ball::medal_military: First of all, thank you for contributing! :medal_military::confetti_ball:

## Issue:
- Search for already opened [issues](https://github.com/anton-yurchenko/git-release/issues) before submitting a [new one](https://github.com/anton-yurchenko/git-release/issues/new/choose).
- Provide as much information as you can, even if not requested by an Issue Template.


## Pull Request:
- Open [Pull Request](https://github.com/anton-yurchenko/git-release/pulls) towards **dev** branch.
- Ensure [Pull Request](https://github.com/anton-yurchenko/git-release/pulls) description clearly describes the problem and solution.
- Make sure all Tests are passed and there is no Code Coverage degradation.
- Please follow [AngularJS Commit Message Guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines)

## Other:
#### Require new feature or change of an existing one?
- Suggest your change via [email](email:[email protected]) or [Pull Request](https://github.com/anton-yurchenko/git-release/pulls), do not open an issue on GitHub.

#### Have questions about the source code?
- Feel free to contact me via [email](email:[email protected]), I'll be glad to provide any information required.
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# OS
**/.DS_Store

# IDE
.vscode/
**/__debug_bin
.idea/
**/.DS_Store
vendor/

# project
coverage.txt
/vendor/
/release/
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
## [2.0.0] - 2019-12-28
This is a major release as most of the code was refactored and some behavior was changed, for example "Tag version is set as a release title".

### Fixed
- Artifact files not found caused panic - all files now being validated before release creation
- Custom changelog file now being validated before release creation
- Arguments parsing fixed

### Added
- Unit testing
- Docker image now built from scratch, resulting in decreased size 139.73MB -> 2.43MB, improving action overall speed.
- **app** package
- `ALLOW_EMPTY_CHANGELOG` env.var to allow publishing a release without changelog (default **false**)
- Artifacts (provided as arguments) can now be separated by one of: `new line '\n', pipe '|', space ' ', comma ','`

### Changed
- **local** package renamed to **repository**
- **remote** package splitted into 2 packages: **asset**, **release**
- Tag version is set as a release title

## [1.1.0] - 2019-12-21
### Added
- [PR #3](https://github.com/anton-yurchenko/git-release/pull/3) Allow any prefix to semver tag. (*Thanks to [Taylor Becker](https://github.com/tajobe) for the PR*)

### Fixed
- PreRelease overwriting Draft configuration. (*Thanks to [Taylor Becker](https://github.com/tajobe) for the reporting an issue*)
- PreRelease overwriting Draft configuration. (*Thanks to [Taylor Becker](https://github.com/tajobe) for reporting an issue*)

## [1.0.0] - 2019-10-01
- First stable release.
Expand Down
28 changes: 20 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
FROM golang:1.13.1-alpine
ARG BUILDER=golang:1.13.1-alpine
ARG TESTER=golangci/golangci-lint:latest

LABEL "repository"="https://github.com/anton-yurchenko/git-release"
LABEL "maintainer"="Anton Yurchenko <[email protected]>"
LABEL "version"="1.1.0"
FROM ${TESTER} as test
WORKDIR /opt/src
COPY . .
RUN golangci-lint run ./...
RUN go test ./... -race -coverprofile=coverage.txt -covermode=atomic

FROM ${BUILDER} as build
WORKDIR /opt/src
COPY . .
RUN addgroup -g 1000 appuser &&\
adduser -D -u 1000 -G appuser appuser
RUN apk add --update --no-cache alpine-sdk
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -o /opt/app

RUN go install &&\
go build -o /opt/release &&\
rm -rf /opt/src
ENTRYPOINT [ "/opt/release" ]
FROM scratch
LABEL "repository"="https://github.com/anton-yurchenko/git-release"
LABEL "maintainer"="Anton Yurchenko <[email protected]>"
LABEL "version"="2.0.0"
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build --chown=1000:0 /opt/app /app
ENTRYPOINT [ "/app" ]
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# global
BINARY := $(notdir $(CURDIR))
GO_BIN_DIR := $(GOPATH)/bin
PKGS := $(go list ./... | grep -v /vendor)

# unit tests
test: lint
@echo "unit testing..."
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic

# lint
.PHONY: lint
lint: $(GO_LINTER)
@echo "vendoring..."
@go mod vendor
@go mod tidy
@echo "linting..."
@golangci-lint run ./...

# initialize
.PHONY: init
init:
@rm -f go.mod
@rm -f go.sum
@rm -rf ./vendor
@go mod init

# linter
GO_LINTER := $(GO_BIN_DIR)/golangci-lint
$(GO_LINTER):
@echo "installing linter..."
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint

.PHONY: release
release: test
@rm -rf ./release
@mkdir -p release
@GOOS=linux GOARCH=amd64 go build -o ./release/app

.PHONY: codecov
codecov: test
@go tool cover -html=coverage.txt
41 changes: 23 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# git-release
[![License](https://img.shields.io/github/license/anton-yurchenko/git-release?style=flat-square)](LICENSE.md) [![Release](https://img.shields.io/github/v/release/anton-yurchenko/git-release?style=flat-square)](https://github.com/anton-yurchenko/git-release/releases/latest) [![Docker Build](https://img.shields.io/docker/cloud/build/antonyurchenko/git-release?style=flat-square)](https://hub.docker.com/r/antonyurchenko/git-release) [![Docker Pulls](https://img.shields.io/docker/pulls/antonyurchenko/git-release?style=flat-square)](https://hub.docker.com/r/antonyurchenko/git-release)
[![Release](https://img.shields.io/github/v/release/anton-yurchenko/git-release)](https://github.com/anton-yurchenko/git-release/releases/latest) [![codecov](https://codecov.io/gh/anton-yurchenko/git-release/branch/master/graph/badge.svg)](https://codecov.io/gh/anton-yurchenko/git-release) [![Go Report Card](https://goreportcard.com/badge/github.com/anton-yurchenko/git-release)](https://goreportcard.com/report/github.com/anton-yurchenko/git-release) [![Docker Build](https://img.shields.io/docker/cloud/build/antonyurchenko/git-release)](https://hub.docker.com/r/antonyurchenko/git-release) [![Docker Pulls](https://img.shields.io/docker/pulls/antonyurchenko/git-release)](https://hub.docker.com/r/antonyurchenko/git-release) [![License](https://img.shields.io/github/license/anton-yurchenko/git-release)](LICENSE.md)

A GitHub Action for creating a GitHub Release with Assets and Changelog whenever a Version Tag is pushed to the project.

Expand All @@ -13,37 +13,42 @@ A GitHub Action for creating a GitHub Release with Assets and Changelog whenever
## Manual:
1. Add your changes to **CHANGELOG.md** in the following format (according to [keepachangelog.com](https://keepachangelog.com/en/1.0.0/ "Keep a ChangeLog")):
```
## [2.1.5] - 2019-10-01
## [2.0.0] - 2019-12-21
### Added
- Feature 1.
- Feature 2.
- Feature A
- Feature B
- GitHub Actions as a CI system
- GitHub Release as an Artifactory system
### Changed
- Logger timestamp.
- User API
### Removed
- Old library.
- Configuration file.
- Previous CI build
- Previous Artifactory
```
2. Tag a commit with Version (according to [semver.org](https://semver.org/ "Semantic Versioning")).
- Extensions like **alpha/beta/rc/...** are not supported.
- Prefixes like **release-/v/...** are supported.
- **Postfixes are not supported**.
3. Push and watch **Git-Release** publishing a Release on GitHub ;-)
![PIC](docs/images/log.png)

## Configuration:
1. Change the workflow to be triggered on Tag Push:
- Use either `'*'` or `'v*`
- Use either `'*'` or a more specific like `'v*'` or `'release-*'`
```
on:
push:
tags:
- 'v*'
```
2. Add Release stage to your workflow:
- **Optional**: Provide a list of assets as **args**
- **Optional**: `DRAFT_RELEASE: "true"/"false"` - Save release as draft instead of publishing it (default `false`).
- **Optional**: `PRE_RELEASE: "true"/"false"` - GitHub will point out that this release is identified as non-production ready (default `false`).
- **Optional**: `CHANGELOG_FILE: "changes.md"` - Changelog filename (default `CHANGELOG.md`).
2. Add Release stage to your workflow:
- Customize configuration with env.vars:
- Provide a list of assets as **args**
- `DRAFT_RELEASE: "true"` - Save release as draft instead of publishing it (default `false`).
- `PRE_RELEASE: "true"` - GitHub will point out that this release is identified as non-production ready (default `false`).
- `CHANGELOG_FILE: "changes.md"` - Changelog filename (default `CHANGELOG.md`).
- `ALLOW_EMPTY_CHANGELOG: "true"` - Allow publishing a release without changelog (default `false`).
```
- name: Release
uses: docker://antonyurchenko/git-release:latest
Expand All @@ -54,13 +59,13 @@ on:
CHANGELOG_FILE: "CHANGELOG.md"
with:
args: |
build/release/artifact-darwin-amd64.zip
build/release/artifact-linux-amd64.zip
build/release/artifact-windows-amd64.zip
build/release/darwin-amd64.zip
build/release/linux-amd64.zip
build/release/windows-amd64.zip
```

## Remarks:
- This action is automatically built at Docker Hub, and tagged with `latest / v1 / v1.0 / v1.0.0`. You may lock to a certain version instead of using **latest**. (*Recommended to lock against a major version, for example* `v1`).
- This action is automatically built at Docker Hub, and tagged with `latest / v2 / v2.0 / v2.0.0`. You may lock to a certain version instead of using **latest**. (*Recommended to lock against a major version, for example* `v2`).
- Instead of using pre-built image, you may build it during the execution of your flow by changing `docker://antonyurchenko/git-release:latest` to `anton-yurchenko/git-release@master`

## License
Expand Down
Binary file modified docs/images/log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/release.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
module git-release
module github.com/anton-yurchenko/git-release

go 1.12
go 1.13

require (
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.0.0 // indirect
github.com/pkg/errors v0.8.1
github.com/sirupsen/logrus v1.4.2
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
github.com/spf13/afero v1.2.2
github.com/stretchr/testify v1.4.0
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6
)
19 changes: 16 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
Expand All @@ -9,22 +10,34 @@ github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASu
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6 h1:pE8b58s1HRDMi8RDc79m0HISf9D4TzseP40cEA6IGfs=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Loading

0 comments on commit 98c7748

Please sign in to comment.