Skip to content

Commit

Permalink
feat(ci): add CI/CD configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
vareversat committed Apr 14, 2024
1 parent 087f9cc commit 2efba57
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/action.go.lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Action - Go lint

on:
workflow_call:
inputs:
go_version:
description: 'The Go version used (ex: 1.21.4)'
required: true
type: string

permissions:
checks: write
contents: write

jobs:
lint:
name: 'Lint'
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4.1.1
- name: 'Setup Go action'
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ inputs.go_version }}
- name: 'Run linters'
uses: wearerequired/lint-action@v2
with:
gofmt: true
github_token: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .github/workflows/action.go.list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Action - Go List

on:
workflow_call:
inputs:
go_version:
description: 'The Go version used (ex: 1.21.4)'
required: true
type: string

jobs:
list:
name: 'List'
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4.1.1
- name: 'Setup Go action'
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ inputs.go_version }}
- name: 'Go list package'
run: go list -m 'github.com/${{ github.repository }}@${{ github.ref_name }}-${{ github.sha }}'
with:
GOPROXY: proxy.golang.org
28 changes: 28 additions & 0 deletions .github/workflows/action.go.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Action - Go test

on:
workflow_call:
inputs:
go_version:
description: 'The Go version used (ex: 1.21.4)'
required: true
type: string

jobs:
test:
name: 'Test'
runs-on: ubuntu-latest
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4.1.1
- name: 'Setup Go action'
uses: actions/setup-go@v5.0.0
with:
go-version: ${{ inputs.go_version }}
- name: 'Go test (with coverage)'
run: go test ./... -covermode=atomic -coverprofile='coverage.out'
- name: 'Upload coverage report'
uses: codecov/codecov-action@v4.1.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.out
44 changes: 44 additions & 0 deletions .github/workflows/action.release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Action - Release

on:
workflow_call:

jobs:
changelog:
runs-on: ubuntu-latest
name: 'Craft the Changelog'
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: "Generate CHANGELOG.md"
uses: heinrichreimer/action-github-changelog-generator@v2.4
with:
token: ${{ secrets.GITHUB_TOKEN }}
output: CHANGELOG.md
onlyLastTag: true
- name: 'Upload CHANGELOG.md'
uses: actions/upload-artifact@v4.3.1
with:
name: changelog
path: CHANGELOG.md
release:
runs-on: ubuntu-latest
name: 'Publish the Release'
needs: [ changelog ]
steps:
- name: 'Checkout source code'
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: 'Download CHANGELOG artifacts'
uses: actions/download-artifact@v4.1.4
with:
path: changelog
name: changelog
- name: 'Generate Github release'
uses: softprops/action-gh-release@v2
with:
name: 'New release (${{ github.ref_name }}) ! 📦'
body_path: changelog/CHANGELOG.md
15 changes: 15 additions & 0 deletions .github/workflows/push.default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Workflow - Default push

on:
push:

jobs:
go-lint:
uses: ./.github/workflows/action.go.lint.yaml
with:
go_version: '1.22.x'
go-test:
uses: ./.github/workflows/action.go.test.yaml
secrets: inherit
with:
go_version: '1.22.x'
25 changes: 25 additions & 0 deletions .github/workflows/push.tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Workflow - Push tag

on:
push:
tags:
- v*

jobs:
go-lint:
uses: ./.github/workflows/action.go.lint.yaml
with:
go_version: '1.22.x'
go-test:
uses: ./.github/workflows/action.go.test.yaml
secrets: inherit
with:
go_version: '1.22.x'
go-list:
uses: ./.github/workflows/action.go.list.yaml
secrets: inherit
with:
go_version: '1.22.x'
release:
needs: [ go-build ]
uses: ./.github/workflows/action.release.yaml

0 comments on commit 2efba57

Please sign in to comment.