Skip to content

CI

CI #10

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
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v3
id: git-cliff
with:
config: cliff.toml
args: -r . --latest
env:
OUTPUT: RELEASE_CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: copy release changelog
run: |
mkdir -p release_notes
cat RELEASE_CHANGELOG.md > release_notes/RELEASE_CHANGELOG.md
- name: upload release changelog
uses: actions/upload-artifact@master
with:
name: release-changelog
path: release_notes
# ================
# RELEASE JOB
# runs after a successful build
# only runs on push "*" tag
# ================
release:
needs: [build, golangci, changelog]
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: retrieve release changelog
uses: actions/download-artifact@master
with:
name: release-changelog
path: release_notes
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/v')
with:
distribution: goreleaser
version: latest
args: release --clean --release-notes release_notes/RELEASE_CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload assets
uses: actions/upload-artifact@v4
with:
name: eoldate
path: dist/*