Skip to content

CI

CI #2

Workflow file for this run

name: CI
# Controls when the action will run. Triggers the workflow on push with tags
on:
push:
tags:
- '*'
pull_request:
permissions:
contents: write
# packages: write
# issues: write
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# The "build" workflow
build:
# The type of runner that the job will run on
strategy:
matrix:
go-version: [1.21, 1.22, 1.23]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Setup Go
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true
# Run build of the application
- name: Run build
run: |
go env -w GOFLAGS=-mod=mod
go mod tidy
go build -v -o eoldate ./cmd/eoldate/main.go
golangci:
needs: build
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: 1.22
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
# Optional: golangci-lint command line arguments.
args: --config ./.golangci-lint.yml
changelog:
needs: [build, golangci]
if: startsWith(github.ref, 'refs/tags/v')
name: Generate changelog
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v3
with:
config: cliff.toml
args: --verbose
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Commit
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
set +e
git add CHANGELOG.md
git commit -m "Update changelog"
git push origin HEAD:main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ================
# RELEASE JOB
# runs after a successful build
# only runs on push "*" tag
# ================
release:
needs: [build, golangci]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Setup Go
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.22
cache: true
- name: Set GOPATH
run: |
echo "GOPATH=$(go env GOPATH)/bin" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/v')
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload assets
uses: actions/upload-artifact@v4
with:
name: eoldate
path: dist/*