Skip to content

Commit

Permalink
ci: add github actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kilianpaquier committed Feb 26, 2024
1 parent 0d432f9 commit 24d45ff
Show file tree
Hide file tree
Showing 8 changed files with 295 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .craft
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
license: mit
ci: github
maintainers:
- url: kilianpaquier.com
name: kilianpaquier
no_api: true
no_chart: true
no_ci: true
no_dockerfile: true
no_sonar: true
25 changes: 25 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Code generated by craft; DO NOT EDIT.

name: Go Dependency Submission
run-name: Go Dependency Submission

on:
push:
branches:
- main

permissions:
contents: write

jobs:

go-dependencies-submission:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: actions/go-dependency-submission@v2
with:
go-mod-path: go.mod
81 changes: 81 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Code generated by craft; DO NOT EDIT.

name: Go Integration
run-name: Go Integration

on:
- push
- workflow_dispatch

jobs:

version:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.semantic_release.outputs.new_release_version }}
steps:
- uses: actions/checkout@v4
- id: sha
run: echo "sha=$(echo "${{ github.ref_name }}" | sha256sum | cut -c -8)" >> $GITHUB_OUTPUT
- id: semantic_release
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/commit-analyzer
@semantic-release/exec
@semantic-release/git
@semantic-release/github
@semantic-release/release-notes-generator
conventional-changelog-conventionalcommits
semantic-release-license
ci: false
dry_run: true
tag_format: v${version}
branches: |
[
"(master|main)",
"v+([0-9])?(.{+([0-9]),x}).x",
{ "name": "next", "prerelease": true },
{ "name": "beta", "prerelease": true },
{ "name": "alpha", "prerelease": true },
{ "name": "staging", "prerelease": "beta" },
{ "name": "develop", "prerelease": "alpha" },
{ "name": "${{ github.ref_name }}", "prerelease": "${{ steps.sha.outputs.sha }}" }
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo ${{ steps.semantic_release.outputs.new_release_version }}

go-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
token: ${{ secrets.GITHUB_TOKEN }}
- uses: golangci/golangci-lint-action@v4
with:
args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format colored-line-number

go-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
token: ${{ secrets.GITHUB_TOKEN }}
- run: CGO_ENABLED="0" go test ./... -coverpkg=./... -covermode=count -coverprofile=coverage.out
- uses: codecov/codecov-action@v4
with:
disable_search: true
fail_ci_if_error: true
file: coverage.out
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}
123 changes: 123 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Code generated by craft; DO NOT EDIT.

name: Release
run-name: Release

on:
workflow_dispatch:

jobs:

version:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.semantic_release.outputs.new_release_version }}
steps:
- uses: actions/checkout@v4
- id: sha
run: echo "sha=$(echo "${{ github.ref_name }}" | sha256sum | cut -c -8)" >> $GITHUB_OUTPUT
- id: semantic_release
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/commit-analyzer
@semantic-release/exec
@semantic-release/git
@semantic-release/github
@semantic-release/release-notes-generator
conventional-changelog-conventionalcommits
semantic-release-license
ci: false
dry_run: true
tag_format: v${version}
branches: |
[
"(master|main)",
"v+([0-9])?(.{+([0-9]),x}).x",
{ "name": "next", "prerelease": true },
{ "name": "beta", "prerelease": true },
{ "name": "alpha", "prerelease": true },
{ "name": "staging", "prerelease": "beta" },
{ "name": "develop", "prerelease": "alpha" },
{ "name": "${{ github.ref_name }}", "prerelease": "${{ steps.sha.outputs.sha }}" }
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: echo ${{ steps.semantic_release.outputs.new_release_version }}

go-build:
runs-on: ubuntu-latest
needs:
- version
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
token: ${{ secrets.GITHUB_TOKEN }}
- uses: goreleaser/goreleaser-action@v5
with:
args: release --clean --skip=validate --skip=announce --skip=publish --snapshot
env:
VERSION: ${{ needs.version.outputs.version }}
- uses: actions/upload-artifact@v4
with:
name: executables
path: |
!dist/*.json
!dist/*.yaml
!dist/*/
checksums.txt
dist/*
retention-days: 1

release:
runs-on: ubuntu-latest
environment: release
if: github.ref_protected == true
permissions:
contents: write
issues: write
needs:
- go-build
env:
GIT_AUTHOR_NAME: ${{ github.triggering_actor }}
GIT_AUTHOR_EMAIL: ${{ github.triggering_actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ github.triggering_actor }}
GIT_COMMITTER_EMAIL: ${{ github.triggering_actor }}@users.noreply.github.com
steps:
- uses: actions/checkout@v4
- id: sha
run: echo "sha=$(echo "${{ github.ref_name }}" | sha256sum | cut -c -8)" >> $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
with:
name: executables
- id: semantic-release
uses: cycjimmy/semantic-release-action@v4
with:
extra_plugins: |
@semantic-release/changelog
@semantic-release/commit-analyzer
@semantic-release/exec
@semantic-release/git
@semantic-release/github
@semantic-release/release-notes-generator
conventional-changelog-conventionalcommits
semantic-release-license
tag_format: v${version}
branches: |
[
"(master|main)",
"v+([0-9])?(.{+([0-9]),x}).x",
{ "name": "next", "prerelease": true },
{ "name": "beta", "prerelease": true },
{ "name": "alpha", "prerelease": true },
{ "name": "staging", "prerelease": "beta" },
{ "name": "develop", "prerelease": "alpha" },
{ "name": "${{ github.ref_name }}", "prerelease": "${{ steps.sha.outputs.sha }}" }
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 8 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@ issues:
- funlen
- goconst
- maintidx
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
max-issues-per-linter: 0
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 0

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
Expand Down
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ builds:
env:
- CGO_ENABLED=0
ldflags:
- -X github.com/kilianpaquier/go-builder-generator/internal/cobra.version={{ .Version }}
- -X github.com/kilianpaquier/go-builder-generator/internal/cobra.version={{ .Env.VERSION }}
goos:
- linux
- windows
Expand Down Expand Up @@ -35,7 +35,7 @@ archives:
format: zip

checksum:
name_template: "checksums.txt"
name_template: checksums.txt

nfpms:
- maintainer: kilianpaquier
Expand Down
54 changes: 54 additions & 0 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Code generated by craft; DO NOT EDIT.

plugins:
- - "@semantic-release/commit-analyzer"
- releaseRules:
- { breaking: true, release: major }
- { revert: true, release: patch }
- { type: feat, release: minor }
- { type: fix, release: patch }
- { type: revert, release: patch }
- { type: perf, release: patch }
- { type: docs, release: patch }
- { type: chore, release: patch }
- { type: refactor, release: minor }
- { scope: release, release: false }
parserOpts:
noteKeywords:
- BREAKING CHANGE
- BREAKING CHANGES
- BREAKING
- - "@semantic-release/release-notes-generator"
- preset: conventionalcommits
presetConfig:
types:
- { type: feat, section: Features }
- { type: fix, section: Bug Fixes }
- { type: revert, section: Reverts }
- { type: perf, section: Performance Improvements }
- { type: docs, section: Documentation }
- { type: chore, section: Chores }
- { type: refactor, section: Code Refactoring }

- { type: build, section: Build System, hidden: true }
- { type: ci, section: Continuous Integration, hidden: true }
- { type: style, section: Styles, hidden: true }
- { type: test, section: Tests, hidden: true }
parserOpts:
noteKeywords:
- BREAKING CHANGE
- BREAKING CHANGES
- BREAKING
- "@semantic-release/changelog"
- "semantic-release-license"
- - "@semantic-release/git"
- assets: [ "CHANGELOG.md", "LICENSE" ]
message: "chore(release): v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
- - "@semantic-release/github"
- assets:
- { path: CHANGELOG.md, label: CHANGELOG.md }
- { path: checksums.txt }
- { path: dist/* }
failComment: false,
successComment: 🎉 This issue has been resolved in version v${nextRelease.version} 🎉
- "@semantic-release/exec"
13 changes: 0 additions & 13 deletions sonar.properties

This file was deleted.

0 comments on commit 24d45ff

Please sign in to comment.