From 486255ba1209339eaf1655f35feb2e964e4a1ffa Mon Sep 17 00:00:00 2001 From: Malek Adawi <91701218+m-adawi@users.noreply.github.com> Date: Tue, 16 Jul 2024 00:10:40 +0300 Subject: [PATCH] setup semantic-release (#5) * test semantic release * test * test * fix: test * fix: test * fix: test * fix: test --- .github/workflows/docker-ci.yaml | 30 ++++++++++++++++-------------- .releaserc.yaml | 7 ++++++- web.go | 2 +- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/docker-ci.yaml b/.github/workflows/docker-ci.yaml index fce9f56..b240495 100644 --- a/.github/workflows/docker-ci.yaml +++ b/.github/workflows/docker-ci.yaml @@ -3,10 +3,10 @@ name: Build and push docker image on: push: paths: - - "**.go" - - "go.mod" - - "go.sum" - - "Dockerfile" + # - "**.go" + # - "go.mod" + # - "go.sum" + # - "Dockerfile" branches: - main - gin-server @@ -22,19 +22,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v3 + + - name: Build docker image + uses: docker/build-push-action@v6 with: - node-version: "lts/*" + load: true - - name: Release + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v4 + id: release env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: npx semantic-release + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Login to Docker registry uses: docker/login-action@v3 @@ -43,8 +44,9 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push + - name: Push docker image uses: docker/build-push-action@v6 + if: ${{ steps.release.outputs.new_release_published == 'true' }} with: push: true - tags: ghcr.io/${{ github.repository }}:latest \ No newline at end of file + tags: ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ steps.release.outputs.new_release_version }} \ No newline at end of file diff --git a/.releaserc.yaml b/.releaserc.yaml index fb59449..54c440f 100644 --- a/.releaserc.yaml +++ b/.releaserc.yaml @@ -1,2 +1,7 @@ branches: - - main \ No newline at end of file + - main + - gin-server +plugins: + - "@semantic-release/commit-analyzer" + - "@semantic-release/release-notes-generator" + - "@semantic-release/github" diff --git a/web.go b/web.go index 555e687..16b2733 100644 --- a/web.go +++ b/web.go @@ -17,4 +17,4 @@ func init(){ func runWebServer() { err := router.Run("localhost:8080") handleInitError(err) -} \ No newline at end of file +}