Skip to content

feat: shell completion support & merge install into init (#22) #8

feat: shell completion support & merge install into init (#22)

feat: shell completion support & merge install into init (#22) #8

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
jobs:
build:
strategy:
matrix:
include:
- platform: ubuntu-latest
goos: linux
goarch: amd64
can_test: true
- platform: ubuntu-latest
goos: linux
goarch: arm64
can_test: false
- platform: windows-latest
goos: windows
goarch: amd64
can_test: true
- platform: windows-latest
goos: windows
goarch: arm64
can_test: false
- platform: macos-latest
goos: darwin
goarch: amd64
can_test: false
- platform: macos-latest
goos: darwin
goarch: arm64
can_test: true
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.21.x'
cache: false
- name: Install dependencies
run: go mod download
- name: Build codes
shell: bash
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: '0'
run: |
if [ "${{ matrix.goos }}" = "windows" ]; then
go build -o codes.exe ./cmd/codes
else
go build -o codes ./cmd/codes
fi
- name: Test
if: matrix.can_test
shell: bash
run: |
if [ "${{ matrix.goos }}" = "windows" ]; then
./codes.exe version
else
./codes version
fi
- name: Set binary name
id: binary
shell: bash
run: |
if [ "${{ matrix.goos }}" = "windows" ]; then
echo "name=codes.exe" >> $GITHUB_OUTPUT
else
echo "name=codes" >> $GITHUB_OUTPUT
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: codes-${{ matrix.goos }}-${{ matrix.goarch }}
path: ${{ steps.binary.outputs.name }}
retention-days: 7
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release files
run: |
mkdir -p release
for dir in artifacts/codes-*; do
platform=$(basename $dir | sed 's/codes-//')
if [ -f "$dir/codes.exe" ]; then
mv "$dir/codes.exe" "release/codes-$platform.exe"
elif [ -f "$dir/codes" ]; then
mv "$dir/codes" "release/codes-$platform"
fi
done
ls -la release/
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: release/*
draft: false
prerelease: false
body: |
Cross-platform builds for codes CLI tool
- Linux (amd64, arm64)
- Windows (amd64, arm64)
- macOS (amd64, arm64)