From af513d746dda44c8eb26f097c10338f4c163022c Mon Sep 17 00:00:00 2001 From: vadimi Date: Fri, 16 Aug 2024 14:14:40 -0400 Subject: [PATCH] add github actions CI --- .github/workflows/build.yml | 73 +++++++++++++++++++++++++++++++++++++ .goreleaser.yml | 1 + 2 files changed, 74 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..daade70 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,73 @@ +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@v6 + with: + version: "~> v2" + 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 + needs: build + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') + + steps: + - name: download artifacts + uses: actions/download-artifact@v4 + 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} + + - uses: ncipollo/release-action@v1 + with: + artifacts: "pkg/grpc-client-cli*" + tag: ${{ github.ref }} + name: ${{ github.ref }} + body: | + v${{ steps.prep.outputs.tags }} + draft: false + prerelease: true diff --git a/.goreleaser.yml b/.goreleaser.yml index df9d9e3..07b487b 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,3 +1,4 @@ +version: 2 builds: - binary: grpc-client-cli main: ./cmd/grpc-client-cli