Skip to content

modified: go.mod

modified: go.mod #6

Workflow file for this run

name: Go
on:
workflow_dispatch:
inputs:
target:
description: 'Build target (server, tablet, redmi)'
required: true
default: 'server'
type: choice
options:
- server
- tablet
- redmi
push:
branches: [ "master" ]
tags:
- v*
pull_request:
branches: [ "master" ]
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
- name: Set build variables
id: vars
run: |
if [[ "${{ github.event.inputs.target }}" == "tablet" ]]; then
echo "GOOS=android" >> $GITHUB_ENV
echo "GOARCH=arm" >> $GITHUB_ENV
echo "GOARM=7" >> $GITHUB_ENV
echo "SUFFIX=tablet" >> $GITHUB_ENV
elif [[ "${{ github.event.inputs.target }}" == "redmi" ]]; then
echo "GOOS=android" >> $GITHUB_ENV
echo "GOARCH=arm64" >> $GITHUB_ENV
echo "SUFFIX=redmi" >> $GITHUB_ENV
else
echo "GOOS=linux" >> $GITHUB_ENV
echo "GOARCH=arm" >> $GITHUB_ENV
echo "GOARM=5" >> $GITHUB_ENV
echo "SUFFIX=server" >> $GITHUB_ENV
fi
- name: Compile
run: |
mkdir -p dist
if [[ -n "${GOARM}" ]]; then
GOOS="${GOOS}" GOARCH="${GOARCH}" GOARM="${GOARM}" \
go build -v -x -ldflags="-X main.name=ccat -X main.version=$(git describe --abbrev=0 --tags) -X main.commit=$(git rev-parse --short HEAD)" \
-o dist/ccat-${SUFFIX}
else
GOOS="${GOOS}" GOARCH="${GOARCH}" \
go build -v -x -ldflags="-X main.name=ccat -X main.version=$(git describe --abbrev=0 --tags) -X main.commit=$(git rev-parse --short HEAD)" \
-o dist/ccat-${SUFFIX}
fi
- name: Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
files: dist/*
name: Release ${{ github.ref_name }}
body: |
Released by: ${{ github.actor }}