Go version #3
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 | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
go-version: ['1.20', '1.21'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go-version }} | |
cache: true | |
- name: Install dependencies | |
run: | | |
go mod download | |
# Install golangci-lint | |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin | |
# Install gosec | |
go install github.com/securego/gosec/v2/cmd/gosec@latest | |
- name: Format Check | |
run: make fmt | |
- name: Lint Check | |
run: make lint | |
- name: Security Check | |
run: make sec | |
- name: Run Tests | |
run: make test | |
- name: Generate Coverage | |
run: make coverage | |
- name: Upload Coverage | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-report | |
path: coverage.out | |
- name: Build | |
run: make build | |
- name: Upload Binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: reqparser-${{ runner.os }}-${{ matrix.go-version }} | |
path: reqparser | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Build Release Binary | |
run: | | |
make build | |
tar czf reqparser-linux-amd64.tar.gz reqparser | |
- name: Create Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
reqparser-linux-amd64.tar.gz | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |