Skip to content

add github actions CI #2

add github actions CI

add github actions CI #2

Workflow file for this run

name: build
on:
push:
branches:
- main
- "feature/**"
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v5
with:
go-version: 1.23
- name: test
run: |
export GOTESTSUM_VERSION=1.12.0
curl -L https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz | sudo tar -C /usr/local/bin -xz
gotestsum --format short-verbose --no-summary=skipped ./...
- name: build
uses: goreleaser/goreleaser-action@master
with:
version: latest
args: --skip=publish,validate --clean --snapshot
- name: prepare dist directory
run: |
find ./dist/ -not -name '*.tar.gz' -not -name '*.zip' -not -name 'dist' -not -wholename './dist/grpc-client-cli_linux_amd*' -not -name 'pkg' -delete
- name: store artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: |
dist
release:
name: release
outputs:
release_url: ${{ steps.create_release.outputs.upload_url }}
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: download artifacts
uses: actions/download-artifact@v3
with:
name: dist
- name: prep
id: prep
run: |
find . -name "grpc-client-cli*" -type f -exec chmod +x {} \;
echo ::set-output name=tags::${GITHUB_REF#refs/tags/v}
- name: create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
v${{ steps.prep.outputs.tags }}
draft: false
prerelease: true
upload-artifacts:
name: upload-artifacts
needs: release
runs-on: ubuntu-latest
steps:
- name: download artifacts
uses: actions/download-artifact@v2
with:
name: dist
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: pkg/grpc-client-cli*
tag: ${{ github.ref }}
overwrite: true
file_glob: true