Skip to content

Commit

Permalink
add github actions CI
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimi committed Aug 16, 2024
1 parent 7117b3f commit 4e8d9fd
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
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
cp Dockerfile dist/
- 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

0 comments on commit 4e8d9fd

Please sign in to comment.