//go:build tools// +build toolspackagemain// These imports are to force `go mod tidy` not to remove that tools we depend// on development. This is explained in great detail in// https://marcofranssen.nl/manage-go-tools-via-go-modules/import ( _ "github.com/mitchellh/gox")
build
make 파일을 사용해서 빌드를 해보자.
프로젝트에 Makefile을 만들자.
vi Makefile
clean -> setup -> build-binaries 로 동작한다.
make build-binaries를 하면 패키지를 빌드한다.
ci/cd setup
.gitlab-ci.yml
yaml yank를 이용해서 yaml을 줄엿다. 기본적으로는 *binaries에 위에 binary를 다 넣어주면 된다.
binaries darwin/amd64 이게 작업 이름인데 이것중요 darwin/amd64를 가져와서 그걸 make에 보내주면 make가 빌드를 하는 구조이다.
artifact를 이용하여 저장을 해두는것이다. 이렇게 해두면 ui에서 다운로드를 받을수 있다.
upload artifact to package & registries
vi .gitlab-ci.yml
아까 설정해둔 variable 을 사용한다.
for문을 돌면서 파일을 업로드한다.
실행하면 다음과 같이 패키지에 업로드 됨을 알수있다.
release
vi .gitlab-ci.yml
일단 git에 로그를 읽어와서 description이라는 환경변수 사용해야하므로 파일에 적어둔후 artifact에 추가해준다. 나중에 $DESCRIPTION 이러면 다른 작업에서 사용할수 있다.