diff --git a/.github/workflows/action.go.lint.yaml b/.github/workflows/action.go.lint.yaml new file mode 100644 index 0000000..d0ef504 --- /dev/null +++ b/.github/workflows/action.go.lint.yaml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/action.go.list.yaml b/.github/workflows/action.go.list.yaml new file mode 100644 index 0000000..dcae806 --- /dev/null +++ b/.github/workflows/action.go.list.yaml @@ -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 diff --git a/.github/workflows/action.go.test.yaml b/.github/workflows/action.go.test.yaml new file mode 100644 index 0000000..2521345 --- /dev/null +++ b/.github/workflows/action.go.test.yaml @@ -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 \ No newline at end of file diff --git a/.github/workflows/action.release.yaml b/.github/workflows/action.release.yaml new file mode 100644 index 0000000..9fdf5b6 --- /dev/null +++ b/.github/workflows/action.release.yaml @@ -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 \ No newline at end of file diff --git a/.github/workflows/push.default.yaml b/.github/workflows/push.default.yaml new file mode 100644 index 0000000..4c94b24 --- /dev/null +++ b/.github/workflows/push.default.yaml @@ -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' \ No newline at end of file diff --git a/.github/workflows/push.tag.yaml b/.github/workflows/push.tag.yaml new file mode 100644 index 0000000..5e70069 --- /dev/null +++ b/.github/workflows/push.tag.yaml @@ -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 \ No newline at end of file