Skip to content

CICD

CICD #6

Workflow file for this run

# Code generated by craft; DO NOT EDIT.
name: CICD
run-name: CICD
on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
push:
branches:
- alpha
- beta
- dev
- develop
- development
- next
- staging
- main
- master
- v[0-9]+.x
- v[0-9]+.[0-9]+.x
workflow_dispatch:
inputs:
release:
description: Run release job by checking this box.
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
run-workflow:
name: Run Workflow
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false && github.ref_protected != true) }}
steps:
- id: skip
run: echo "Running workflow"
version:
name: Version
runs-on: ubuntu-latest
needs: run-workflow
if: ${{ github.event_name != 'pull_request' }}
outputs:
version: ${{ steps.version.outputs.version }}
permissions:
contents: write
issues: write
pull-requests: write
id-token: none
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# https://github.com/marketplace/actions/action-for-semantic-release
- id: semrel_version
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: true
semantic_version: 24
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: version
run: |
if [ "${SEMREL_INFO_NEXT_VERSION}" != "" ]; then
echo "version=v${SEMREL_INFO_NEXT_VERSION#v}" >> $GITHUB_OUTPUT
else
DESCRIBE=$(git describe --tags || echo "v0.0.0")
echo "version=v${DESCRIBE#v}" >> $GITHUB_OUTPUT
fi
env:
SEMREL_INFO_NEXT_VERSION: ${{ steps.semrel_version.outputs.new_release_version }}
- run: echo ${VERSION}
env:
VERSION: ${{ steps.version.outputs.version }}
go-vulncheck:
name: Go Vulnerability Check
runs-on: ubuntu-latest
needs: run-workflow
steps:
- uses: golang/govulncheck-action@v1
with:
check-latest: true
go-package: ./...
go-version-file: go.mod
go-lint:
name: Go Lint
runs-on: ubuntu-latest
needs: run-workflow
permissions:
checks: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
cache: false
check-latest: true
go-version-file: go.mod
token: ${{ secrets.GITHUB_TOKEN }}
- run: mkdir -p reports/
- uses: golangci/golangci-lint-action@v6
with:
args: --config .golangci.yml --timeout 240s --fast --sort-results --out-format checkstyle:reports/go-ci-lint.checkstyle.xml,colored-line-number
go-test:
name: Go Test
runs-on: ${{ matrix.os }}
needs: run-workflow
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: go.mod
token: ${{ secrets.GITHUB_TOKEN }}
- run: mkdir -p reports/
- run: go test ./... -coverpkg="./..." -covermode="count" -coverprofile="reports/go-coverage.native.out" -timeout=15s
- uses: codecov/codecov-action@v5
with:
codecov_yml_path: .codecov.yml
disable_search: true
env_vars: OS
fail_ci_if_error: false
files: reports/go-coverage.native.out
flags: ${{ matrix.os }}
slug: ${{ github.repository }}
token: ${{ secrets.CODECOV_TOKEN }}
env:
OS: ${{ matrix.os }}
go-build:
name: Go Build
runs-on: ubuntu-latest
needs:
- version
- go-test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
check-latest: true
go-version-file: go.mod
token: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/marketplace/actions/goreleaser-action
- if: ${{ hashFiles('.goreleaser.yml') != '' }}
uses: goreleaser/goreleaser-action@v6
with:
args: release --clean --config .goreleaser.yml --skip=validate --skip=announce --skip=publish --snapshot
env:
VERSION: ${{ needs.version.outputs.version }}
- uses: actions/upload-artifact@v4
with:
name: build
# order is important to filter unwanted globs after the filter or desired globs
path: |
dist/*
!dist/*.json
!dist/*.yaml
!dist/*/
retention-days: 1
release:
name: Release
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' && github.ref_protected }}
environment:
name: release
url: ${{ steps.environment_url.outputs.environment_url }}
needs:
- go-build
permissions:
contents: write
issues: write
pull-requests: write
id-token: none
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: build
path: dist
# https://github.com/marketplace/actions/action-for-semantic-release
- id: semrel_version
uses: cycjimmy/semantic-release-action@v4
with:
dry_run: ${{ inputs.release == 'false' }}
semantic_version: 24
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: environment_url
run: |
if [ "${VERSION}" != "" ]; then
echo "environment_url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/tag/v${VERSION#v}" >> $GITHUB_OUTPUT
fi
env:
VERSION: ${{ steps.semrel_version.outputs.new_release_version }}