ci: Set up CI/CD pipeline with GoReleaser integration #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
release: | |
types: [created] | |
jobs: | |
build-test-lint: | |
name: Build, Test, and Lint | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
go-version: ['1.22.x', 'stable'] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
cache: true | |
- name: Install dependencies | |
run: go mod download | |
- name: Install golangci-lint | |
uses: golangci/golangci-lint-action@v4 | |
with: | |
version: latest | |
- name: Run golangci-lint | |
uses: golangci/golangci-lint-action@v4 | |
with: | |
args: --timeout 5m | |
release: | |
name: Build and Release | |
runs-on: ubuntu-latest | |
needs: build-test-lint | |
if: github.event_name == 'release' && github.event.action == 'created' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: stable | |
cache: true | |
- name: Set up Goreleaser | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
version: latest | |
- name: Run Goreleaser | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
args: release --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
security: | |
name: CodeQL Analysis | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
contents: read | |
security-events: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: go | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v2 |