From 9d8bc2ddbddd620325af9566700435127ab694e9 Mon Sep 17 00:00:00 2001 From: Azis Alvriyanto Date: Sat, 28 Dec 2024 23:39:44 +0700 Subject: [PATCH] ci: integrate goreleaser action for release management --- .github/workflows/release.yml | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..05592a74 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Release Version + +on: + push: + tags: + - "v*" + +permissions: write-all + +jobs: + build: + name: Build and Testing + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... + + release: + name: Release + runs-on: ubuntu-latest + needs: [build] + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ vars.DOCKER_USERNAME }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Init tag version name + run: | + echo "TAG_VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV + + - name: Release + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: "~> v2" + args: release --clean --config ./deployments/goreleaser.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_USERNAME: ${{ vars.DOCKER_USERNAME }} + DOCKER_REPOSITORY: ${{ vars.DOCKER_REPOSITORY }} + TAG_VERSION: ${{ env.TAG_VERSION }}