Skip to content

Commit dd92ca8

Browse files
authored
ci: [DDS-514] Added Release GitHub workflow (#24)
- Added `Release` GitHub workflow. - Made `call-build` job dependent on `call-lint` job. - Disabled caching in `actions/setup-go` before `golangci/golangci-lint-action` to avoid golangci/golangci-lint-action#23. - Made some minor corrections.
1 parent 856f0bb commit dd92ca8

File tree

6 files changed

+170
-59
lines changed

6 files changed

+170
-59
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ defaults:
55
run:
66
shell: bash
77

8+
env:
9+
BIN_NAME: cheqd-noded
810

911
jobs:
10-
1112
build-binary:
1213
name: "Node binary"
1314
runs-on: ubuntu-20.04
1415

1516
steps:
1617
- uses: actions/checkout@v3
17-
18+
1819
- uses: actions/setup-go@v4
1920
with:
2021
go-version-file: ./go.mod
21-
cache: true
2222

2323
- name: Run GoReleaser
2424
uses: goreleaser/goreleaser-action@v4
@@ -30,8 +30,8 @@ jobs:
3030
- name: Store artifact
3131
uses: actions/upload-artifact@v3
3232
with:
33-
name: cheqd-noded
34-
path: dist/linux-amd64_linux_amd64_v1/cheqd-noded
33+
name: ${{ env.BIN_NAME }}-linux
34+
path: dist/linux-amd64_linux_amd64_v1/${{ env.BIN_NAME }}
3535

3636
build-docker:
3737
name: "Docker image"

.github/workflows/dispatch.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
name: "Workflow Dispatch"
22
on: push
3-
concurrency:
3+
concurrency:
44
group: ${{ github.workflow }}-${{ github.ref }}
55
cancel-in-progress: true
66

7-
87
jobs:
9-
108
call-lint:
119
name: "Lint"
1210
uses: ./.github/workflows/lint.yml
1311
secrets: inherit
1412

1513
call-build:
1614
name: "Build"
15+
needs: call-lint
1716
uses: ./.github/workflows/build.yml
1817
secrets: inherit
19-
18+
2019
call-test:
2120
name: "Tests"
22-
needs: [ call-lint, call-build ]
21+
needs: call-build
2322
uses: ./.github/workflows/test.yml
2423
secrets: inherit
24+
25+
call-release:
26+
name: "Release"
27+
needs: call-test
28+
if: ${{ github.ref_type == 'tag' }}
29+
uses: ./.github/workflows/release.yml
30+
secrets: inherit

.github/workflows/lint.yml

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,44 @@ defaults:
55
run:
66
shell: bash
77

8-
98
jobs:
10-
119
sh-euox-pipefail-check:
1210
name: "Shell pipefail check"
1311
runs-on: ubuntu-20.04
14-
12+
1513
steps:
1614
- uses: actions/checkout@v3
1715

1816
- name: Run 'set -euox pipefail' check
1917
run: bash ./.github/scripts/ensure_set_euox_pipefail.sh
20-
18+
2119
md-link-check:
2220
name: "Broken Markdown links"
2321
runs-on: ubuntu-20.04
24-
22+
2523
steps:
2624
- uses: actions/checkout@v3
2725

2826
- name: Run Markdown link check
2927
uses: gaurav-nelson/github-action-markdown-link-check@v1
3028
with:
31-
config-file: '.github/linters/mlc_config.json'
32-
use-quiet-mode: 'yes'
33-
29+
config-file: ".github/linters/mlc_config.json"
30+
use-quiet-mode: "yes"
31+
3432
go-lint:
3533
# We can't use VALIDATE_GO from super linter because of this issue:
3634
# https://github.com/github/super-linter/issues/143
3735
name: "Golang"
3836
runs-on: ubuntu-20.04
39-
37+
4038
steps:
4139
- uses: actions/checkout@v3
4240

4341
- uses: actions/setup-go@v4
4442
with:
4543
go-version-file: ./go.mod
46-
cache: true
47-
44+
cache: false # to bypass https://github.com/golangci/golangci-lint-action/issues/23
45+
4846
- name: Run golangci-lint
4947
uses: golangci/golangci-lint-action@v3
5048
with:
@@ -56,49 +54,49 @@ jobs:
5654
runs-on: ubuntu-20.04
5755
steps:
5856
- uses: actions/checkout@v3
59-
57+
6058
# Install the `buf` CLI
6159
- uses: bufbuild/[email protected]
6260
with:
6361
github_token: ${{ secrets.GITHUB_TOKEN }}
64-
62+
6563
# Lint
6664
- uses: bufbuild/buf-lint-action@v1
6765
with:
6866
input: proto
6967

7068
# Breaking change detection
7169
# - uses: bufbuild/buf-breaking-action@v1
72-
# with:
73-
# input: proto
74-
# against: 'https://github.com/canow-co/cheqd-node.git#branch=develop,ref=HEAD~1,subdir=proto'
70+
# with:
71+
# input: proto
72+
# against: 'https://github.com/canow-co/cheqd-node.git#branch=develop,ref=HEAD~1,subdir=proto'
7573

7674
super-lint:
7775
name: "Super Linter"
7876
runs-on: ubuntu-20.04
79-
77+
8078
steps:
81-
- uses: actions/checkout@v3
82-
with:
83-
fetch-depth: 0 # Required to fetch version
84-
85-
- name: Run Super Linter
86-
uses: github/super-linter/slim@v5
87-
env:
88-
IGNORE_GITIGNORED_FILES: true
89-
DEFAULT_BRANCH: main
90-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
91-
LOG_LEVEL: WARN
92-
VALIDATE_ALL_CODEBASE: false
93-
MULTI_STATUS: true
94-
95-
VALIDATE_BASH: true
96-
VALIDATE_DOCKERFILE_HADOLINT: true
97-
VALIDATE_ENV: true
98-
VALIDATE_GITHUB_ACTIONS: true
99-
VALIDATE_JSON: true
100-
VALIDATE_MARKDOWN: true
101-
VALIDATE_OPENAPI: true
102-
VALIDATE_PYTHON_PYLINT: true
103-
VALIDATE_XML: true
104-
VALIDATE_YAML: true
79+
- uses: actions/checkout@v3
80+
with:
81+
fetch-depth: 0 # Required to fetch version
82+
83+
- name: Run Super Linter
84+
uses: github/super-linter/slim@v5
85+
env:
86+
IGNORE_GITIGNORED_FILES: true
87+
DEFAULT_BRANCH: main
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
LOG_LEVEL: WARN
90+
VALIDATE_ALL_CODEBASE: false
91+
MULTI_STATUS: true
92+
93+
VALIDATE_BASH: true
94+
VALIDATE_DOCKERFILE_HADOLINT: true
95+
VALIDATE_ENV: true
96+
VALIDATE_GITHUB_ACTIONS: true
97+
VALIDATE_JSON: true
98+
VALIDATE_MARKDOWN: true
99+
VALIDATE_OPENAPI: true
100+
VALIDATE_PYTHON_PYLINT: true
101+
VALIDATE_XML: true
102+
VALIDATE_YAML: true

.github/workflows/pull-request.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ jobs:
2020
lint-pr:
2121
name: "PR format check"
2222
runs-on: ubuntu-latest
23-
23+
permissions:
24+
pull-requests: read
25+
2426
steps:
2527
- uses: actions/checkout@v3
2628

2729
- uses: amannn/[email protected]
2830
env:
29-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3032
with:
3133
# Configure which types are allowed (newline delimited).
3234
# Default: https://github.com/commitizen/conventional-commit-types

.github/workflows/release.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: "Release"
2+
on:
3+
workflow_call:
4+
defaults:
5+
run:
6+
shell: bash
7+
8+
env:
9+
BIN_NAME: cheqd-noded
10+
11+
jobs:
12+
release-binary:
13+
name: "Node binary"
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
outputs:
18+
RELEASE_VERSION: ${{ steps.set-version.outputs.RELEASE_VERSION }}
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0 # to fetch all history
24+
25+
- name: Set release version number
26+
id: set-version
27+
run: |
28+
RELEASE_VERSION=$( git describe --tags "${{ github.sha }}")
29+
echo "RELEASE_VERSION=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
30+
31+
- name: Download binary artifact
32+
uses: actions/download-artifact@v3
33+
id: download
34+
with:
35+
path: release/
36+
37+
- name: Display structure of downloaded files
38+
run: ls -R
39+
working-directory: release
40+
41+
- name: Archive application binary
42+
run: |
43+
tar czf release/cheqd-node-${{ steps.set-version.outputs.RELEASE_VERSION }}-linux.tar.gz LICENSE README.md -C release/${{ env.BIN_NAME }}-linux ${{ env.BIN_NAME }}
44+
shell: bash
45+
46+
- name: Publish the Release
47+
uses: softprops/action-gh-release@v1
48+
with:
49+
prerelease: true
50+
tag_name: ${{ steps.set-version.outputs.RELEASE_VERSION }}
51+
target_commitish: ${{ github.sha }}
52+
files: release/*
53+
generate_release_notes: true
54+
55+
release-docker:
56+
name: "Docker image"
57+
needs: release-binary
58+
runs-on: ubuntu-latest
59+
permissions:
60+
contents: read
61+
packages: write
62+
env:
63+
IMAGE_NAME: ${{ github.repository }}
64+
65+
steps:
66+
- uses: actions/checkout@v3
67+
68+
- name: Set up Docker Buildx
69+
uses: docker/setup-buildx-action@v2
70+
id: buildx
71+
with:
72+
version: latest
73+
74+
- name: Login to GitHub Container Registry
75+
uses: docker/login-action@v2
76+
with:
77+
registry: ghcr.io
78+
username: ${{ github.actor }}
79+
password: ${{ secrets.GITHUB_TOKEN }}
80+
81+
- name: Configure Docker image metadata
82+
id: meta
83+
uses: docker/metadata-action@v4
84+
with:
85+
images: |
86+
ghcr.io/${{ env.IMAGE_NAME }}
87+
flavor: |
88+
latest=auto
89+
tags: |
90+
type=semver,pattern={{version}},value=${{ needs.release-binary.outputs.RELEASE_VERSION }}
91+
type=raw,value=production-latest
92+
type=sha,format=long
93+
labels: |
94+
org.opencontainers.image.vendor="Canow"
95+
org.opencontainers.image.created={{date 'dddd, MMMM Do YYYY, h:mm:ss a'}}
96+
# org.opencontainers.image.documentation=""
97+
98+
- name: Build and push image
99+
uses: docker/build-push-action@v3
100+
with:
101+
context: .
102+
file: docker/Dockerfile
103+
platforms: linux/amd64
104+
push: true
105+
tags: ${{ steps.meta.outputs.tags }}
106+
labels: ${{ steps.meta.outputs.labels }}
107+
cache-from: type=gha
108+
cache-to: type=gha,mode=min

.github/workflows/test.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ permissions:
1212
checks: write
1313

1414
jobs:
15-
1615
unit-tests:
1716
name: "Unit Tests"
1817
runs-on: ubuntu-20.04
@@ -23,7 +22,6 @@ jobs:
2322
- uses: actions/setup-go@v4
2423
with:
2524
go-version-file: ./go.mod
26-
cache: true
2725

2826
- name: Install ginkgo
2927
working-directory: ./..
@@ -50,7 +48,7 @@ jobs:
5048
uses: actions/download-artifact@v3
5149
id: download
5250
with:
53-
name: cheqd-noded
51+
name: cheqd-noded-linux
5452
path: ${{ env.RUNNER_BIN_DIR }}
5553

5654
- name: Restore binary permissions
@@ -86,7 +84,6 @@ jobs:
8684
- uses: actions/setup-go@v4
8785
with:
8886
go-version-file: ./go.mod
89-
cache: true
9087

9188
- name: Install ginkgo
9289
working-directory: ./..
@@ -133,8 +130,8 @@ jobs:
133130
134131
- uses: mikepenz/action-junit-report@v3
135132
with:
136-
report_paths: 'report.xml'
133+
report_paths: "report.xml"
137134
check_name: ""
138-
suite_regex: '*'
135+
suite_regex: "*"
139136
include_passed: true
140137
detailed_summary: true

0 commit comments

Comments
 (0)