Skip to content

Merge pull request #1 from Intility/feature/templates #1

Merge pull request #1 from Intility/feature/templates

Merge pull request #1 from Intility/feature/templates #1

Workflow file for this run

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Latest Release
defaults:
run:
shell: bash
jobs:
lint:
name: Lint files
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.54
test:
name: Run tests
runs-on: 'ubuntu-latest'
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.22'
- run: go test -v -cover
build:
name: Build binaries
runs-on: 'ubuntu-latest'
needs: test
strategy:
matrix:
goosarch:
- 'darwin/arm64'
- 'darwin/amd64'
- 'linux/arm64'
- 'linux/amd64'
- 'windows/amd64'
# etc
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Build binary
run: |
GOOSARCH=${{matrix.goosarch}}
GOOS=${GOOSARCH%/*}
GOARCH=${GOOSARCH#*/}
BINARY_NAME=cwc-$GOOS-$GOARCH
if [ "$GOOS" = "windows" ]; then
BINARY_NAME="$BINARY_NAME".exe
fi
go build -o "$BINARY_NAME" -v
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
echo "GOOS=$GOOS" >> $GITHUB_ENV
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: ${{env.BINARY_NAME}}
path: ${{env.BINARY_NAME}}
release:
name: Create Release
runs-on: 'ubuntu-latest'
needs: [ build ]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all binaries
uses: actions/download-artifact@v4
- name: Release Notes
run: |
git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s%n * %an <%ae>' --no-merges >> ".github/RELEASE-TEMPLATE.md"
- name: Create Release with Notes
uses: softprops/action-gh-release@v1
with:
body_path: ".github/RELEASE-TEMPLATE.md"
draft: false
files: "**/cwc-*"
token: ${{secrets.GITHUB_TOKEN}}