Skip to content

Commit

Permalink
CI: Add goreleaser for release (milvus-io#97)
Browse files Browse the repository at this point in the history
Signed-off-by: zhuwenxing <[email protected]>
  • Loading branch information
zhuwenxing authored Feb 22, 2023
1 parent 8a8fb4a commit fcaa02b
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 0 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

name: release

on:
push:
tags:
- 'v*'
workflow_dispatch:

permissions:
contents: write

jobs:
build-linux-binary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v3
with:
go-version: 1.18
cache: true

- uses: goreleaser/goreleaser-action@v4
with:
# either 'goreleaser' (default) or 'goreleaser-pro':
distribution: goreleaser
version: latest
args: release --skip-publish --config .goreleaser-linux.yaml
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
- name: Upload
uses: actions/upload-artifact@v3
with:
name: birdwatcher-linux
path: |
dist/birdwatcher*
dist/checksums.txt
build-darwin-binary:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v3
with:
go-version: 1.18
cache: true

- uses: goreleaser/goreleaser-action@v4
with:
# either 'goreleaser' (default) or 'goreleaser-pro':
distribution: goreleaser
version: latest
args: release --skip-publish --config .goreleaser-darwin.yaml
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
- name: Upload
uses: actions/upload-artifact@v3
with:
name: birdwatcher-darwin
path: |
dist/birdwatcher*
dist/checksums.txt
merge-and-release:
needs: [build-linux-binary, build-darwin-binary]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v3
with:
go-version: 1.18
cache: true
- name: Make directories
run: |
mkdir -p ./birdwatcher-build/linux
mkdir -p ./birdwatcher-build/darwin
- name: Download linux binaries
uses: actions/download-artifact@v3
with:
name: birdwatcher-linux
path: ./birdwatcher-build/linux
- name: Download darwin binaries
uses: actions/download-artifact@v3
with:
name: birdwatcher-darwin
path: ./birdwatcher-build/darwin
- name: Merge checksum file
run: |
cd ./birdwatcher-build
cat ./darwin/checksums.txt >> checksums.txt
cat ./linux/checksums.txt >> checksums.txt
rm ./darwin/checksums.txt
rm ./linux/checksums.txt
- name: Check git status
run: |
tree
git status
- name: Release
uses: goreleaser/goreleaser-action@v4
with:
args: release --clean --config .goreleaser-release.yaml
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
*.bak
.idea
bin/

dist/

birdwatcher-build
41 changes: 41 additions & 0 deletions .goreleaser-darwin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
#- go generate ./...
builds:
- env:
- CGO_ENABLED=1
goos:
# - linux
#- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

# The lines beneath this are called `modelines`. See `:help modeline`
# 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
49 changes: 49 additions & 0 deletions .goreleaser-linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
#- go generate ./...
builds:
- env:
- CGO_ENABLED=1
goos:
- linux
#- windows
#- darwin
goarch:
- amd64
overrides:
- goos: linux
goarch: amd64
env:
- CC=gcc
ldflags:
- -extldflags "-static"
archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

# The lines beneath this are called `modelines`. See `:help modeline`
# 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
20 changes: 20 additions & 0 deletions .goreleaser-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
builds:
- skip: true
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
release:
draft: true
mode: append
extra_files:
- glob: ./birdwatcher-build/**/*.tar.gz
- glob: ./birdwatcher-build/checksums.txt
name_template: "Release {{.Tag}}"
header: |
# What's Changed
## 🚀 Features
## 🎄 Enhancements
## 🐛 Bug Fixes

0 comments on commit fcaa02b

Please sign in to comment.