Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: automate release process #829

Merged
merged 9 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@ name: Release
# This job will only be triggered when a tag (vX.X.x) is pushed
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10

- 'v[0-9]+.[0-9]+.[0-9]+*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Go
uses: actions/[email protected]
with:
go-version: 1.18
- name: Unshallow
run: git fetch --prune --unshallow
- name: Create release
uses: goreleaser/goreleaser-action@v4
with:
args: release --rm-dist --release-notes ./RELEASE_NOTES.md
fetch-depth: 0
- run: git fetch --force --tags
- name: Build & Publish release
run: |
make release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_MOUNT_CONFIG: true
GORELEASER_IMAGE: line/goreleaserx-wasm:1.0.0-0.10.0
GORELEASER_RELEASE: true
BUILD_TAGS: static
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83 changes: 65 additions & 18 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,74 @@
---
project_name: lbm-sdk

release:
github:
owner: line
name: lbm-sdk

before:
hooks:
- go mod tidy
builds:
- skip: true
- id: simd-linux-amd64
main: ./simapp/simd
binary: simd
goos:
- linux
goarch:
- amd64
env:
- CGO_ENABLED=1
flags:
- -mod=readonly
- -trimpath
- "-tags={{ .Env.BUILD_TAGS }}"
ldflags:
- "{{ .Env.BUILD_VARS }}"

archives:
- format: tar.gz
-
id: bin-archive
builds:
- simd-linux-amd64
format: tar.gz
name_template: "simd_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
wrap_in_directory: true
format_overrides:
- goos: windows
format: zip
name_template: "{{ .Binary }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
files:
- LICENSE
- README.md
- NOTICE
- RELEASE_CHANGELOG.md

checksum:
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
snapshot:
name_template: SNAPSHOT-{{ .Commit }}

name_template: "{{ incpatch .Version }}-next"
changelog:
skip: true
use: git
sort: asc
groups:
- title: "Breaking Changes"
regexp: '^.*?BREAKING CHANGE(\([[:word:]]+\))??!?:.+$'
order: 0
- title: Features
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 1
- title: 'Bug Fixes'
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 2
- title: 'Build, CI'
regexp: '^.*?(ci|build)(\([[:word:]]+\))??!?:.+$'
order: 3
- title: 'Document Updates'
regexp: '^.*?docs(\([[:word:]]+\))??!?:.+$'
order: 4
- title: Improvements
regexp: '^.*?(test|refactor|perf)(\([[:word:]]+\))??!?:.+$'
order: 5
- title: Others
order: 999

release:
github:
owner: line
name: lbm-sdk
prerelease: auto
mode: replace
draft: false


# modelines, feel free to remove those if you don't want/use them:
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (rest) [\#807](https://github.com/line/lbm-sdk/pull/807) remove legacy REST API

### Build, CI
* (ci) [\#829](https://github.com/line/lbm-sdk/pull/829) automate release process

### Document Updates
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ Other notes:
A convenience git `pre-commit` hook that runs the formatters automatically
before each commit is available in the `contrib/githooks/` directory.

## Commit Convention
All commits pushed to `lbm-sdk` are classified according to the rules below.
Therefore, it cannot be included in the release notes unless you properly assign the prefix to the commit. For example, you can write commit message like `feat: this is new feature`. However, if you want to clarify the scope of the commit, you can write it as follows `feat(x/token): this is new feature`.
- `chore` : a commit of the type chore makes trivial changes. If you don't want to include specific commit in the release note, add this prefix.
- `feat` : a commit of the type feat introduces a new feature to the codebase
- `fix` : a commit of the type fix patches a bug in your codebase
- `refactor` : A code change that neither fixes a bug nor adds a feature
- `BREAKING CHANGE` : a commit of the type breaking changes to the codebase. This changes breaks down the backward compatibility
- `perf` : A code change that improves performance
- `test`: Adding missing tests or correcting existing tests
- `docs`: Documentation only changes
- `build`: Changes that affect the build system or external dependencies
- `ci`: Changes to our CI configuration files and scripts

## Pull Requests

To accommodate review process we suggest that PRs are categorically broken up.
Expand Down
65 changes: 65 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,68 @@ libsodium:
$(MAKE) install; \
fi
.PHONY: libsodium

###############################################################################
### release ###
###############################################################################

GORELEASER_CONFIG ?= .goreleaser.yml

GORELEASER_BUILD_LDF = $(ldflags)
GORELEASER_BUILD_LDF += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
GORELEASER_BUILD_LDF := $(strip $(GORELEASER_BUILD_LDF))

GORELEASER_SKIP_VALIDATE ?= false
GORELEASER_DEBUG ?= false
GORELEASER_IMAGE ?= line/goreleaserx-wasm:1.0.0-0.10.0
GORELEASER_RELEASE ?= false
#GO_MOD_NAME := $(shell go list -m 2>/dev/null)
GO_MOD_NAME := github.com/line/lbm-sdk

ifeq ($(GORELEASER_RELEASE),true)
GORELEASER_SKIP_VALIDATE := false
GORELEASER_SKIP_PUBLISH := release --skip-publish=false
else
GORELEASER_SKIP_PUBLISH := --skip-publish=true
GORELEASER_SKIP_VALIDATE ?= false
GITHUB_TOKEN=
endif

ifeq ($(GORELEASER_MOUNT_CONFIG),true)
GORELEASER_IMAGE := -v $(HOME)/.docker/config.json:/root/.docker/config.json $(GORELEASER_IMAGE)
endif

release-snapshot:
docker run --rm \
-e BUILD_TAGS="$(build_tags)" \
-e BUILD_VARS='$(GORELEASER_BUILD_LDF)' \
-e GITHUB_TOKEN="$(GITHUB_TOKEN)" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(shell pwd):/go/src/$(GO_MOD_NAME) \
-w /go/src/$(GO_MOD_NAME) \
$(GORELEASER_IMAGE) \
build --snapshot \
-f "$(GORELEASER_CONFIG)" \
--skip-validate=$(GORELEASER_SKIP_VALIDATE) \
--debug=$(GORELEASER_DEBUG) \
--rm-dist
release:
docker run --rm \
-e BUILD_TAGS="$(build_tags)" \
-e BUILD_VARS='$(GORELEASER_BUILD_LDF)' \
-e GITHUB_TOKEN="$(GITHUB_TOKEN)" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(shell pwd):/go/src/$(GO_MOD_NAME) \
-w /go/src/$(GO_MOD_NAME) \
$(GORELEASER_IMAGE) \
$(GORELEASER_SKIP_PUBLISH) \
-f "$(GORELEASER_CONFIG)" \
--skip-validate=$(GORELEASER_SKIP_VALIDATE) \
--skip-announce=true \
--debug=$(GORELEASER_DEBUG) \
--rm-dist

build-static: go.sum
CGO_ENABLED=1 go build -mod=readonly -tags "$(build_tags)" -ldflags '$(GORELEASER_BUILD_LDF)' -trimpath -o ./build/ ./...

.PHONY: release-snapshot release build-static