Skip to content

ci(.github/workflows): Add Tag and Release workflow #2

ci(.github/workflows): Add Tag and Release workflow

ci(.github/workflows): Add Tag and Release workflow #2

Workflow file for this run

name: Tag and Release
on:
push:
tags:
- 'v*'
env:
BINARY_NAME: "prettylogs"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.23.3'
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
run: make test
build:
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
targets:
- name: "macos"
cmd: make build-macos
artifact: "wave1_darwin"
- name: "macos-apple-silicon"
cmd: make build-macos-arm
artifact: "wave1_apple_silicon"
- name: "linux-amd64"
cmd: make build-linux
artifact: "wave1_linux_amd64"
- name: "linux-arm64"
cmd: make build-linux-arm
artifact: "wave1_linux_arm64"
- name: "windows"
cmd: make build-windows
artifact: "wave1_windows.exe"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.23.3'
- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build ${{ matrix.targets.name }}
run: ${{ matrix.targets.cmd }}
- name: Upload Build Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.targets.name }}
path: "bin/${{ matrix.targets.artifact }}"
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Generate Release Body
id: release_body
run: |
echo "body<<EOF" >> $GITHUB_OUTPUT
echo "Changelog:" >> $GITHUB_OUTPUT
git log $(git describe --tags --abbrev=0)..HEAD --oneline >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release and Upload Assets
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GH_PERSONAL_TOKEN }}
name: Release ${{ github.ref_name }}
body: ${{ steps.release_body.outputs.body }}
files: artifacts/**/*