Skip to content

Commit

Permalink
ci: Add automated semantic release using Goreleaser (#357)
Browse files Browse the repository at this point in the history
Co-authored-by: Ankur Banerjee <ankurdotb@users.noreply.github.com>
  • Loading branch information
Andrew Nikitin and ankurdotb committed Aug 17, 2022
1 parent 9e1d54b commit b7c19fe
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 585 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Expand Up @@ -52,6 +52,7 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version-file: ./go.mod
cache: true

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/codeql.yml
Expand Up @@ -31,14 +31,15 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.17
go-version-file: ./go.mod

- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required to fetch version

- name: Build
run: make proto-gen build
run: |
make proto-gen build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
20 changes: 8 additions & 12 deletions .github/workflows/release.yml
Expand Up @@ -21,11 +21,11 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required to fetch version
persist-credentials: false

- uses: actions/setup-go@v3
with:
go-version-file: ./go.mod
cache: true

# Node.js setup is needed to run Semantic Release
- uses: actions/setup-node@v3
Expand All @@ -34,10 +34,6 @@ jobs:
cache: 'npm'
cache-dependency-path: '**/package-lock.json'

# Setup for pushing to Buf.build later
- uses: bufbuild/buf-setup-action@v1.7.0

# Required for short-lived token provided to Semantic Release
- name: "Obtain Github App token"
id: app-token
uses: getsentry/action-github-app-token@v1.0.6
Expand Down Expand Up @@ -68,12 +64,6 @@ jobs:
RELEASE_VERSION=$( git describe --tags ${{ github.sha }})
echo ::set-output name=RELEASE_VERSION::"$RELEASE_VERSION"
# Push Protobufs to Buf.build registry
- uses: bufbuild/buf-push-action@v1
with:
input: proto
buf_token: ${{ secrets.BUF_TOKEN }}

release-docker:
name: "Docker image"
needs: release-binary
Expand All @@ -83,11 +73,14 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required to fetch version
persist-credentials: false

- uses: actions/setup-go@v3
with:
go-version-file: ./go.mod
cache: true

- name: Generate golang code
run: make proto-gen

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -112,6 +105,9 @@ jobs:
tags: |
type=semver,pattern={{version}},value=${{ needs.release-binary.outputs.RELEASE_VERSION }}
labels: |
org.opencontainers.image.title="cheqd Node Docker Image"
org.opencontainers.image.description="Node for cheqd network"
org.opencontainers.image.source="https://github.com/cheqd/cheqd-node"
org.opencontainers.image.vendor="Cheqd Foundation Limited"
org.opencontainers.image.created={{date 'dddd, MMMM Do YYYY, h:mm:ss a'}}
org.opencontainers.image.documentation="https://docs.cheqd.io/node"
Expand Down
38 changes: 13 additions & 25 deletions .goreleaser.yml
Expand Up @@ -10,36 +10,17 @@ before:
- make clean
- go mod tidy
- go mod download
- make proto-gen

builds:
- id: ubuntu-latest-amd64
- id: cheqd-linux
main: ./cmd/cheqd-noded
binary: cheqd-noded
targets:
- "linux_amd64"
env:
- CGO_ENABLED=1
flags:
- -mod=readonly
- -tags="netgo ledger"
- -trimpath
ldflags:
- -s -w
- -X github.com/cosmos/cosmos-sdk/version.Name=cheqd-noded
- -X github.com/cosmos/cosmos-sdk/version.AppName=cheqd-noded
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,goleveldb

- id: ubuntu-latest-arm64
main: ./cmd/cheqd-noded
binary: cheqd-noded
targets:
- "linux_arm64"
- linux_amd64
hooks:
pre:
- sudo apt update && sudo apt install clang gcc-multilib g++-multilib -y
pre: make proto-gen
flags:
- -mod=readonly
- -tags="netgo ledger"
Expand All @@ -52,7 +33,6 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,goleveldb


archives:
- id: release-archives
replacements:
Expand All @@ -70,7 +50,8 @@ checksum:
algorithm: sha256

changelog:
use: github-native
use: github
sort: asc
groups:
- title: Features
regexp: "^.*feat[(\\w)]*:+.*$"
Expand All @@ -89,7 +70,14 @@ changelog:
order: 4
- title: 'Other changes'
order: 999

filters:
exclude:
- '^docs'
- '^test'
- '^ci'
- '^refactor'
- '^revert'
- '^style'

release:
github:
Expand Down

0 comments on commit b7c19fe

Please sign in to comment.