From 5cfac01ab1794da29c8f416f62ca024ed1486224 Mon Sep 17 00:00:00 2001 From: Salipa-Gurung Date: Tue, 18 Feb 2025 10:03:02 +0545 Subject: [PATCH] add release job --- .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dced647..8fa2475 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: unit-tests +name: tests-and-release on: pull_request: @@ -6,6 +6,14 @@ on: push: branches: - main + tags: + - "*" + +permissions: + contents: write + +env: + GO_VERSION: "1.22" jobs: unit-test: @@ -17,7 +25,30 @@ jobs: - name: set up go uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: ${{ env.GO_VERSION}} - name: unit tests run: go test ./... + + release: + runs-on: ubuntu-latest + needs: unit-test + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: set up go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION}} + + - name: create release + uses: goreleaser/goreleaser-action@master + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}