Skip to content

Commit

Permalink
build: Automated semantic release with Goreleaser [DEV-1718] (#26)
Browse files Browse the repository at this point in the history
* Create .releaserc.json
* Move golang CI linter config
* Update .goreleaser.yml
* Versioned Docker image numbers
* Fix Golang CI version
* Disable Markdown linting
* Temporarily disable YAML linter
* Fix indentation
  • Loading branch information
ankurdotb authored Sep 8, 2022
1 parent 6f9e39b commit 79bf82f
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .golangci.yaml → .github/linters/.golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
run:
tests: false
# # timeout for analysis, e.g. 30s, 5m, default is 1m
# timeout: 5m
timeout: 10m

linters:
disable-all: true
Expand Down
45 changes: 23 additions & 22 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,33 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
version: v1.28
args: --timeout 10m
args: --config .github/linters/.golangci.yaml

super-lint:
name: "Super Linter"
runs-on: ubuntu-latest

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

- name: Run Super Linter
uses: github/super-linter/slim@v4
env:
IGNORE_GITIGNORED_FILES: true
DEFAULT_BRANCH: "chains/cheqd/mainnet"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LOG_LEVEL: WARN
VALIDATE_ALL_CODEBASE: true
MULTI_STATUS: true
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required to fetch version

- name: Run Super Linter
uses: github/super-linter/slim@v4
env:
IGNORE_GITIGNORED_FILES: true
DEFAULT_BRANCH: "chains/cheqd/testnet"
LINTER_RULES_PATH: '.github/linters'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LOG_LEVEL: WARN
VALIDATE_ALL_CODEBASE: true
MULTI_STATUS: true

VALIDATE_BASH: true
VALIDATE_DOCKERFILE_HADOLINT: true
DOCKERFILE_HADOLINT_FILE_NAME: '../linters/.hadolint.yml'
VALIDATE_GITHUB_ACTIONS: true
VALIDATE_OPENAPI: true
VALIDATE_PYTHON_PYLINT: true
VALIDATE_XML: true
VALIDATE_YAML: true
VALIDATE_BASH: true
VALIDATE_DOCKERFILE_HADOLINT: true
VALIDATE_GITHUB_ACTIONS: true
VALIDATE_JSONC: true
VALIDATE_OPENAPI: true
VALIDATE_PYTHON_PYLINT: true
VALIDATE_XML: true
# VALIDATE_YAML: true
68 changes: 67 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,81 @@ on:
defaults:
run:
shell: bash
permissions:
contents: write
packages: write


jobs:

release-binary:
name: "Binary"
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.set-version.outputs.VERSION }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

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

# Node.js setup is needed to run Semantic Release
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'

- name: "Obtain Github App token"
id: app-token
uses: getsentry/[email protected]
with:
app_id: ${{ secrets.BOT_APP_ID }}
private_key: ${{ secrets.BOT_APP_PRIVATE_KEY }}

- name: "Install Semantic Release dependencies"
run: npm ci

- name: "Execute Semantic Release"
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set version number
id: set-version
run: |
VERSION=$( git describe --tags ${{ github.sha }})
echo ::set-output name=VERSION::"$VERSION"
release-bdjuno:
name: "BDJuno Docker Image"
runs-on: ubuntu-latest
needs: release-binary
env:
IMAGE_NAME: ${{ github.repository }}
COMMIT_SHA: ${{ github.sha }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

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

- name: Set network name
id: set-network
run: |
Expand All @@ -46,9 +105,15 @@ jobs:
uses: docker/metadata-action@v4
with:
images: registry.digitalocean.com/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
tags: |
${{ steps.set-network.outputs.NETWORK_NAME }}-latest
type=semver,pattern={{version}},value=${{ needs.release-binary.outputs.VERSION }}
labels: |
org.opencontainers.image.title="BDJuno for cheqd network"
org.opencontainers.image.description="BDJuno for cheqd network"
org.opencontainers.image.source="https://github.com/cheqd/bdjuno"
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 All @@ -66,6 +131,7 @@ jobs:
- name: Push BDJuno image
run: |
docker push registry.digitalocean.com/${{ env.IMAGE_NAME }}:${{ steps.set-network.outputs.NETWORK_NAME }}-latest
docker push registry.digitalocean.com/${{ env.IMAGE_NAME }}:${{ needs.release-binary.outputs.VERSION }}
release-hasuracli:
name: "Hasura CLI Docker Image"
Expand Down
31 changes: 11 additions & 20 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
# Goreleaser configuration file

project_name: cheqd-bdjuno
project_name: bdjuno

env:
- GO111MODULE=on

before:
hooks:
- make clean
- go mod tidy
- go mod tidy -compat=1.17
- go mod download

builds:
- id: bdjuno-linux
main: ./cmd/bdjuno
binary: bdjuno
env:
- CGO_ENABLED=1
targets:
- linux_amd64
flags:
- -mod=readonly
- -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
- -X github.com/forbole/juno/v3/cmd.Version={{ .Version }}
- -X github.com/forbole/juno/v3/cmd.Commit={{ .Commit }}

archives:
- id: release-archives
Expand All @@ -43,7 +42,6 @@ checksum:

changelog:
use: github-native
sort: asc
groups:
- title: Features
regexp: "^.*feat[(\\w)]*:+.*$"
Expand All @@ -62,19 +60,12 @@ changelog:
order: 4
- title: 'Other changes'
order: 999
filters:
exclude:
- '^docs'
- '^test'
- '^ci'
- '^refactor'
- '^revert'
- '^style'


release:
github:
owner: cheqd
name: cheqd-node
name: bdjuno

draft: false
prerelease: true
Expand Down
44 changes: 44 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"branches": [
"chains/cheqd/mainnet",
{
"name": "chains/cheqd/testnet",
"channel": "beta",
"prerelease": true
}
],
"tagFormat": "${version}",
"ci": true,
"preset": "conventionalcommits",
"plugins": [
[ "@semantic-release/commit-analyzer",
{
"parserOpts": "./.github/linters/.commitlint.rules.js",
"releaseRules": [
{ "breaking": true, "release": "major" },
{ "type": "feat", "release": "minor" },
{ "type": "fix", "release": "patch" },
{ "type": "perf", "release": "patch" },
{ "type": "build", "release": "patch" },
{ "scope": "security", "release": "patch" },
{ "type": "chore", "release": false },
{ "type": "ci", "release": false },
{ "type": "docs", "release": false },
{ "type": "refactor", "release": false },
{ "type": "revert", "release": false },
{ "type": "style", "release": false },
{ "type": "test", "release": false },
{ "scope": "no-release", "release": false },
{ "scope": "release", "release": "patch" }
],
"presetConfig": true
}
],
[ "@semantic-release/git",
{
"assets": [ "package.json" ],
"message": "chore(release): ${nextRelease.version} [skip ci]"
}
]
]
}

0 comments on commit 79bf82f

Please sign in to comment.