Skip to content

modified gh action

modified gh action #2

Workflow file for this run

name: Build
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21
- name: Build
run: |
RELEASE_TAG=$(git describe --tags --exact-match 2>/dev/null || echo "no-tag")
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
TAG="${GITHUB_REF#refs/tags/}"
BINARY_NAME=$( echo ${GITHUB_REPOSITORY} | egrep -io "[^/]+$")
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
HASH=$(git log -n1 --pretty=format:%h)
env GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o ${BINARY_NAME} \
&& cp ${BINARY_NAME} ${BINARY_NAME}_Linux_x86_64 && tar -cvzf ${BINARY_NAME}_Linux_x86_64.tar.gz ${BINARY_NAME} && rm -rf ${BINARY_NAME} \
&& env GOOS=linux CGO_ENABLED=0 GOARCH=arm64 go build -o ${BINARY_NAME} \
&& tar -cvzf ${BINARY_NAME}_Linux_arm64.tar.gz ${BINARY_NAME} && cp ${BINARY_NAME}_Linux_arm64.tar.gz ${BINARY_NAME}_Linux_aarch64.tar.gz && rm -rf ${BINARY_NAME} \
&& env GOOS=darwin CGO_ENABLED=0 GOARCH=amd64 go build -o ${BINARY_NAME} \
&& cp ${BINARY_NAME} ${BINARY_NAME}_Darwin_x86_64 && tar -cvzf ${BINARY_NAME}_Darwin_x86_64.tar.gz ${BINARY_NAME} && rm -rf ${BINARY_NAME} \
&& env GOOS=darwin CGO_ENABLED=0 GOARCH=arm64 go build -o ${BINARY_NAME} \
&& tar -cvzf ${BINARY_NAME}_Darwin_arm64.tar.gz ${BINARY_NAME} && cp ${BINARY_NAME}_Darwin_arm64.tar.gz ${BINARY_NAME}_Darwin_aarch64.tar.gz && rm -rf ${BINARY_NAME} \
&& env GOOS=windows CGO_ENABLED=0 GOARCH=amd64 go build -o ${BINARY_NAME}.exe \
&& zip ${BINARY_NAME}_Windows_x86_64.zip ${BINARY_NAME}.exe \
&& md5sum ${BINARY_NAME}_Linux_x86_64.tar.gz | tee -a checksums.txt \
&& md5sum ${BINARY_NAME}_Linux_arm64.tar.gz | tee -a checksums.txt \
&& md5sum ${BINARY_NAME}_Linux_aarch64.tar.gz | tee -a checksums.txt \
&& md5sum ${BINARY_NAME}_Darwin_x86_64.tar.gz | tee -a checksums.txt \
&& md5sum ${BINARY_NAME}_Darwin_arm64.tar.gz | tee -a checksums.txt \
&& md5sum ${BINARY_NAME}_Darwin_aarch64.tar.gz | tee -a checksums.txt \
&& md5sum ${BINARY_NAME}_Windows_x86_64.zip | tee -a checksums.txt \
&& md5sum ${BINARY_NAME}_Darwin_x86_64 | tee -a checksums.txt \
&& md5sum ${BINARY_NAME}_Linux_x86_64| tee -a checksums.txt
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.RELEASE_TAG }}
files: |
checksums.txt
${{ env.BINARY_NAME }}_Linux_x86_64
${{ env.BINARY_NAME }}_Linux_x86_64.tar.gz
${{ env.BINARY_NAME }}_Linux_arm64.tar.gz
${{ env.BINARY_NAME }}_Linux_aarch64.tar.gz
${{ env.BINARY_NAME }}_Darwin_x86_64
${{ env.BINARY_NAME }}_Darwin_x86_64.tar.gz
${{ env.BINARY_NAME }}_Darwin_arm64.tar.gz
${{ env.BINARY_NAME }}_Darwin_aarch64.tar.gz
${{ env.BINARY_NAME }}_Windows_x86_64.zip
name: "${{ env.RELEASE_TAG }} release"