Skip to content

implement unit tests #3

implement unit tests

implement unit tests #3

Workflow file for this run

name: Release
on: [push]
permissions:
contents: write
env:
GO_VERSION: '>=1.21.0'
NAME: 'inflater'
jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
arch: [ amd64, arm64 ]
exclude:
- os: windows-latest
arch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Setup env
id: setup
shell: bash
run: |
if [[ ${GITHUB_REF} =~ ^refs/tags/v[0-9]+\.[0-9]+ ]] ; then
export VERSION=${GITHUB_REF_NAME}
else
export VERSION=SNAPSHOT
fi
echo "VERSION=${VERSION}" >> $GITHUB_ENV
case ${{ matrix.os }} in
ubuntu-*)
if [ "${{ matrix.arch }}" = "arm64" ] ; then
sudo apt-get update
sudo apt-get -y install gcc-12-aarch64-linux-gnu
echo "CC=aarch64-linux-gnu-gcc-12" >> $GITHUB_ENV
fi
export GOOS=linux
export PKGEXT=.tar.gz
;;
macos-*)
export GOOS=darwin
export PKGEXT=.zip
;;
windows-*)
choco install zip
export GOOS=windows
export PKGEXT=.zip
;;
esac
export GOARCH=${{ matrix.arch }}
echo "GOOS=${GOOS}" >> $GITHUB_ENV
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
echo "CGO_ENABLED=1" >> $GITHUB_ENV
echo "PKGNAME=${NAME}_${VERSION}_${GOOS}_${GOARCH}" >> $GITHUB_ENV
echo "PKGEXT=${PKGEXT}" >> $GITHUB_ENV
- name: Build
shell: bash
run: |
go build
- name: Archive
shell: bash
run: |
rm -rf _build/${PKGNAME}
mkdir -p _build/${PKGNAME}
cp -p ${NAME} _build/${PKGNAME}
cp -p LICENSE _build/${PKGNAME}
cp -p README.md _build/${PKGNAME}
case "${PKGEXT}" in
".tar.gz")
tar cf _build/${PKGNAME}${PKGEXT} -C _build ${PKGNAME}
;;
".zip")
(cd _build && zip -r9q ${PKGNAME}${PKGEXT} ${PKGNAME})
;;
esac
ls -laFR _build
- name: Artifact upload
uses: actions/upload-artifact@v4
with:
name: ${{ env.GOOS }}_${{ env.GOARCH }}
path: _build/${{ env.PKGNAME }}${{ env.PKGEXT }}
create-release:
name: Create release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- build
steps:
- uses: actions/download-artifact@v4
with: { name: darwin_amd64 }
- uses: actions/download-artifact@v4
with: { name: darwin_arm64 }
- uses: actions/download-artifact@v4
with: { name: linux_amd64 }
- uses: actions/download-artifact@v4
with: { name: linux_arm64 }
- uses: actions/download-artifact@v4
with: { name: windows_amd64 }
- run: ls -lafR
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
prerelease: ${{ contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') }}
files: |
*.tar.gz
*.zip
fail_on_unmatched_files: true
generate_release_notes: true
append_body: true
# based on: github.com/koron-go/_skeleton/.github/workflows/release.yml